]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1261] install NULL instead of "" for an empty column for backward
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 5 Oct 2011 06:17:41 +0000 (23:17 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 5 Oct 2011 06:17:41 +0000 (23:17 -0700)
compatibility.  We need this at least until we completely deprecate
the old API.

src/lib/datasrc/sqlite3_accessor.cc

index 69d564951da0e5fb772263b3a9a7d9f2667d17ad..3c2a70595528e5c02c19530f32a213a1da8a4132 100644 (file)
@@ -637,8 +637,12 @@ doUpdate(SQLite3Parameters& dbparams, StatementID stmt_id,
     const size_t column_count =
         sizeof(update_params) / sizeof(update_params[0]);
     for (int i = 0; i < column_count; ++i) {
-        if (sqlite3_bind_text(stmt, ++param_id, update_params[i].c_str(), -1,
-                              SQLITE_TRANSIENT) != SQLITE_OK) {
+        // The old sqlite3 data source API assumes NULL for an empty column.
+        // We need to provide compatibility at least for now.
+        if (sqlite3_bind_text(stmt, ++param_id,
+                              update_params[i].empty() ? NULL :
+                              update_params[i].c_str(),
+                              -1, SQLITE_TRANSIENT) != SQLITE_OK) {
             isc_throw(DataSourceError, "failed to bind SQLite3 parameter: " <<
                       sqlite3_errmsg(dbparams.db_));
         }