diff options
Diffstat (limited to 'modules/extra/m_mysql.cpp')
-rw-r--r-- | modules/extra/m_mysql.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 06cce3143..72cf889c4 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2010-2016 Anope Team + * (C) 2010-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -446,9 +446,17 @@ Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Dat { Anope::string buf; *it->second >> buf; - query.SetValue(it->first, buf); + + bool escape = true; + if (buf.empty()) + { + buf = "NULL"; + escape = false; + } + + query.SetValue(it->first, buf, escape); } - + return query; } @@ -468,7 +476,7 @@ void MySQLService::Connect() if (!connect) throw SQL::Exception("Unable to connect to MySQL service " + this->name + ": " + mysql_error(this->sql)); - + Log(LOG_DEBUG) << "Successfully connected to MySQL service " << this->name << " at " << this->server << ":" << this->port; } @@ -545,4 +553,3 @@ void DispatcherThread::Run() } MODULE_INIT(ModuleSQL) - |