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;
|
||||
|
||||
if (!dbref.IsValid()) {
|
||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||
<< "'" << Escape(dbobj->GetName1()) << "', '" << Escape(dbobj->GetName2()) << "', 1)";
|
||||
if (!dbobj->GetName2().IsEmpty()) {
|
||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||
<< 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());
|
||||
SetObjectID(dbobj, GetLastInsertID());
|
||||
} else {
|
||||
|
|
|
@ -419,9 +419,16 @@ void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
|
|||
std::ostringstream qbuf;
|
||||
|
||||
if (!dbref.IsValid()) {
|
||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||
<< static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
|
||||
<< "E'" << Escape(dbobj->GetName1()) << "', E'" << Escape(dbobj->GetName2()) << "', 1)";
|
||||
if (!dbobj->GetName2().IsEmpty()) {
|
||||
qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
|
||||
<< 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());
|
||||
SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id"));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue