summary refs log tree commit diff stats
path: root/lib/impure/db_sqlite.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/impure/db_sqlite.nim')
-rwxr-xr-xlib/impure/db_sqlite.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim
index 29ff0693e..5196e4807 100755
--- a/lib/impure/db_sqlite.nim
+++ b/lib/impure/db_sqlite.nim
@@ -128,8 +128,10 @@ proc GetValue*(db: TDbConn, query: TSqlQuery,
   ## executes the query and returns the result dataset's the first column 
   ## of the first row. Returns "" if the dataset contains no rows.
   var stmt = setupQuery(db, query, args)
-  if step(stmt) == SQLITE_ROW: 
-    result = newStringOfCap(column_bytes(stmt, 0))
+  if step(stmt) == SQLITE_ROW:
+    let cb = column_bytes(stmt, 0)
+    if cb == 0: return ""
+    result = newStringOfCap(cb)
     add(result, column_text(stmt, 0))
     if finalize(stmt) != SQLITE_OK: dbError(db)
   else: