Store unspecified scheme names in database as empty string, not null.
[cumulus.git] / localdb.cc
index 2f5af6e..cc8a83c 100644 (file)
@@ -85,6 +85,9 @@ void LocalDb::Open(const char *path, const char *snapshot_name,
 
     sqlite3_extended_result_codes(db, 1);
 
+    if (snapshot_scheme == NULL)
+        snapshot_scheme = "";
+
     /* Insert this snapshot into the database, and determine the integer key
      * which will be used to identify it. */
     sqlite3_stmt *stmt = Prepare("insert into "
@@ -92,11 +95,8 @@ void LocalDb::Open(const char *path, const char *snapshot_name,
                                  "values (?, ?, julianday('now'), ?)");
     sqlite3_bind_text(stmt, 1, snapshot_name, strlen(snapshot_name),
                       SQLITE_TRANSIENT);
-    if (snapshot_scheme == NULL)
-        sqlite3_bind_null(stmt, 2);
-    else
-        sqlite3_bind_text(stmt, 2, snapshot_scheme, strlen(snapshot_scheme),
-                          SQLITE_TRANSIENT);
+    sqlite3_bind_text(stmt, 2, snapshot_scheme, strlen(snapshot_scheme),
+                      SQLITE_TRANSIENT);
     sqlite3_bind_double(stmt, 3, intent);
 
     rc = sqlite3_step(stmt);