From a7cbe2a139a6c4f0e8691fb7cc42f478d9f21938 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 14 Nov 2024 13:00:03 +0000 Subject: Add default values to the MySQL tables and use when a column is null. --- modules/extra/mysql.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'modules/extra') diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index caa02d8f0..78dfa81cd 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -164,19 +164,19 @@ public: switch (dt) { case Serialize::DataType::BOOL: - return "TINYINT NOT NULL"; + return "TINYINT NOT NULL DEFAULT 0"; case Serialize::DataType::FLOAT: - return "DOUBLE PRECISION NOT NULL"; + return "DOUBLE PRECISION NOT NULL DEFAULT 0.0"; case Serialize::DataType::INT: - return "BIGINT NOT NULL"; + return "BIGINT NOT NULL DEFAULT 0"; case Serialize::DataType::TEXT: - return "TEXT"; + return "TEXT DEFAULT NULL"; case Serialize::DataType::UINT: - return "BIGINT UNSIGNED NOT NULL"; + return "BIGINT UNSIGNED NOT NULL DEFAULT 0"; } return "TEXT"; // Should never be reached @@ -498,7 +498,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Dat case Serialize::DataType::UINT: { if (buf.empty()) - buf = "0"; + buf = "DEFAULT"; escape = false; break; } @@ -507,7 +507,7 @@ Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Dat { if (buf.empty()) { - buf = "NULL"; + buf = "DEFAULT"; escape = false; } break; -- cgit