summaryrefslogtreecommitdiff
path: root/modules/database
diff options
context:
space:
mode:
Diffstat (limited to 'modules/database')
-rw-r--r--modules/database/db_sql.cpp2
-rw-r--r--modules/database/db_sql_live.cpp3
2 files changed, 3 insertions, 2 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp
index 170f7a5c8..74166d6dc 100644
--- a/modules/database/db_sql.cpp
+++ b/modules/database/db_sql.cpp
@@ -185,7 +185,7 @@ class DBSQL : public Module, public Pipe
void OnSerializableDestruct(Serializable *obj) anope_override
{
Serialize::Type *s_type = obj->GetSerializableType();
- if (s_type)
+ if (s_type && obj->id > 0)
this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
this->updated_items.erase(obj);
}
diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp
index 9a769a35c..ae37a7a9b 100644
--- a/modules/database/db_sql_live.cpp
+++ b/modules/database/db_sql_live.cpp
@@ -156,7 +156,8 @@ class DBMySQL : public Module, public Pipe
Serialize::Type *s_type = obj->GetSerializableType();
if (s_type)
{
- this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
+ if (obj->id > 0)
+ this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id));
s_type->objects.erase(obj->id);
}
this->updated_items.erase(obj);