diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2018-05-09 19:33:58 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-13 09:09:20 +0200 |
commit | af593c2ef3abb323a60ae49e5f1bbb08ffb6262e (patch) | |
tree | 880f48e2a0b4b9fb45ab99e465ae0be8d8f2389d /lib | |
parent | 9048bcc54b5fe8d0ae8c24b9cf7454cfa897ce5a (diff) | |
download | Nim-af593c2ef3abb323a60ae49e5f1bbb08ffb6262e.tar.gz |
Better db_sqlite errors when db_sqlite not connected.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/impure/db_sqlite.nim | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index f88037e2f..b1541c1ba 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -126,6 +126,7 @@ proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {. tags: [ReadDbEffect, WriteDbEffect].} = ## tries to execute the query and returns true if successful, false otherwise. + assert(not db.isNil, "Database not connected.") var q = dbFormat(query, args) var stmt: sqlite3.Pstmt if prepare_v2(db, q, q.len.cint, stmt, nil) == SQLITE_OK: @@ -144,6 +145,7 @@ proc newRow(L: int): Row = proc setupQuery(db: DbConn, query: SqlQuery, args: varargs[string]): Pstmt = + assert(not db.isNil, "Database not connected.") var q = dbFormat(query, args) if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db) @@ -267,6 +269,7 @@ proc tryInsertID*(db: DbConn, query: SqlQuery, {.tags: [WriteDbEffect], raises: [].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. + assert(not db.isNil, "Database not connected.") var q = dbFormat(query, args) var stmt: sqlite3.Pstmt result = -1 |