Open Toromino opened 2 years ago
This is a bit of the fault of the sqlite3 lib since passing an empty string to prepare_v2()
statement causes a misuse error (21) but doesn't set the error message which is SQLITE_OK
message "not an error"
.
sqlite.h:
(#define SQLITE_MISUSE 21 /* Library used incorrectly */)
main.c:
static const char* const aMsg[] = {
/* SQLITE_OK */ "not an error",
...
/* SQLITE_MISUSE */ "bad parameter or other API misuse",
The wrapped sqlite3_exec()
lib function which is a convenience function that does: prepare()
, step()
and finalize()
doesn't return this error and returns an SQLITE_OK even when passed a string that only contains whitespace.
The impure nim library exec()
doesn't call the wrapped sqlite3.exec()
but instead makes it's own prepare()
, step()
and finalize()
calls which means it does not inherit the same behavior as the wrapped sqlite3_exec()
.
Proposed solutions:
1) make db_sqlite.exec()
act like sqlite3.exec()
2) return the proper error message for SQLITE_MISUSE
: "bad parameter or other API misuse"
3) actually use the sqlite3.exec()
to inherit the behavior.
I'm leaning towards option 3
Function
exec
indb_sqlite.nim
throws an unclear error when passing an empty query.Example
Current Output
Possible Solution
Let the empty string pass, or throw a more clear exception.
Additional Information