mirror of https://github.com/Icinga/icinga2.git
Use NULL instead of empty strings for name2 in the icinga_objects table
fixes #6646
This commit is contained in:
parent
f4c0600b26
commit
f86068d5e0
|
@ -421,9 +421,16 @@ void IdoMysqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
|
||||||
std::ostringstream qbuf;
|
std::ostringstream qbuf;
|
||||||
|
|
||||||
if (!dbref.IsValid()) {
|
if (!dbref.IsValid()) {
|
||||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
if (!dbobj->GetName2().IsEmpty()) {
|
||||||
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||||
<< "'" << Escape(dbobj->GetName1()) << "', '" << Escape(dbobj->GetName2()) << "', 1)";
|
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||||
|
<< "'" << Escape(dbobj->GetName1()) << "', '" << Escape(dbobj->GetName2()) << "', 1)";
|
||||||
|
} else {
|
||||||
|
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, is_active) VALUES ("
|
||||||
|
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||||
|
<< "'" << Escape(dbobj->GetName1()) << "', 1)";
|
||||||
|
}
|
||||||
|
|
||||||
Query(qbuf.str());
|
Query(qbuf.str());
|
||||||
SetObjectID(dbobj, GetLastInsertID());
|
SetObjectID(dbobj, GetLastInsertID());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -419,9 +419,16 @@ void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
|
||||||
std::ostringstream qbuf;
|
std::ostringstream qbuf;
|
||||||
|
|
||||||
if (!dbref.IsValid()) {
|
if (!dbref.IsValid()) {
|
||||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
if (!dbobj->GetName2().IsEmpty()) {
|
||||||
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||||
<< "E'" << Escape(dbobj->GetName1()) << "', E'" << Escape(dbobj->GetName2()) << "', 1)";
|
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||||
|
<< "E'" << Escape(dbobj->GetName1()) << "', E'" << Escape(dbobj->GetName2()) << "', 1)";
|
||||||
|
} else {
|
||||||
|
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, is_active) VALUES ("
|
||||||
|
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||||
|
<< "E'" << Escape(dbobj->GetName1()) << "', 1)";
|
||||||
|
}
|
||||||
|
|
||||||
Query(qbuf.str());
|
Query(qbuf.str());
|
||||||
SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id"));
|
SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id"));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue