summaryrefslogtreecommitdiff
path: root/modules/extra/mysql.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-11-14 13:00:03 +0000
committerSadie Powell <sadie@witchery.services>2024-11-14 13:00:03 +0000
commita7cbe2a139a6c4f0e8691fb7cc42f478d9f21938 (patch)
tree0a8281ee22354c298ddefd0a7a3c690de88ea14b /modules/extra/mysql.cpp
parent8408bf95c792d84e26f145ba99a0c79729c9e8bd (diff)
Add default values to the MySQL tables and use when a column is null.
Diffstat (limited to 'modules/extra/mysql.cpp')
-rw-r--r--modules/extra/mysql.cpp14
1 files changed, 7 insertions, 7 deletions
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;