summaryrefslogtreecommitdiff
path: root/src/analysis/db/collection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/collection.c')
-rw-r--r--src/analysis/db/collection.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/analysis/db/collection.c b/src/analysis/db/collection.c
index 91f9872..5e5adb7 100644
--- a/src/analysis/db/collection.c
+++ b/src/analysis/db/collection.c
@@ -997,8 +997,14 @@ static bool g_db_collection_store_item(const GDbCollection *collec, const GDbIte
index++;
break;
+ case SQLITE_NULL:
+ ret = sqlite3_bind_null(stmt, index);
+ index++;
+ break;
+
default:
- ret = SQLITE_OK;
+ assert(false);
+ ret = SQLITE_ERROR;
break;
}
@@ -1090,7 +1096,10 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
sql = stradd(sql, values[i].name);
- sql = stradd(sql, " = ");
+ if (values[i].type == SQLITE_NULL)
+ sql = stradd(sql, " IS ");
+ else
+ sql = stradd(sql, " = ");
if (values[i].type == SQLITE_RAW)
sql = stradd(sql, values[i].cstring);
@@ -1101,12 +1110,10 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
sql = stradd(sql, ";");
- fprintf(stderr, "UPDATE SQL '%s'\n", sql);
-
ret = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
if (ret != SQLITE_OK)
{
- fprintf(stderr, "Can't prepare INSERT statment '%s' (ret=%d): %s\n", sql, ret, sqlite3_errmsg(db));
+ fprintf(stderr, "Can't prepare UPDATE statment '%s' (ret=%d): %s\n", sql, ret, sqlite3_errmsg(db));
goto gdcsi_exit;
}
@@ -1117,7 +1124,7 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
timestamp = find_bound_value(values, count, "timestamp");
assert(timestamp->type == SQLITE_INT64);
- ret = sqlite3_bind_int64(stmt, index, values[i].integer64);
+ ret = sqlite3_bind_int64(stmt, index, timestamp->integer64);
index++;
if (ret != SQLITE_OK)
@@ -1144,8 +1151,14 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
index++;
break;
+ case SQLITE_NULL:
+ ret = sqlite3_bind_null(stmt, index);
+ index++;
+ break;
+
default:
- ret = SQLITE_OK;
+ assert(false);
+ ret = SQLITE_ERROR;
break;
}