A call now doesn't have to do any reflection, it just blindly invokes
a bunch of argument and return value handlers to execute the translation,
and the safety of the translation is determined at registration time.
When specified, changes the default locking at a tx.Begin.
Changelog (v2):
Add a testcase to ensure _txlock is properly handled.
Closes#189
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit introduces a new type 'ErrNo', implementing the error
interface. Constants for all sqlite3 error codes are provided
in the new source file "error.go".
Sometimes it's best to not create files in the directories where code lives...
for example, that directory might be read-only, or folks might be using
source-control or build systems that disallow that behavior. To fix this, we
create a file in the temp directory and use it instead.
We don't use ioutil.TempFile(), since that actually creates the file, and we'd
like the tests to run as if the file had never existed. We use 16 bytes from
crypto/rand to avoid people doing bad things with symlinks in the temp
directory.
SQLite3 stores timestamps very naively -- they're completely untyped,
and can contain any value. The previous implementation always inserts
values in the 'datetime' format, and returns an error when attempting to
extract a field with a different format.
Some legacy databases, unfortunately, were generated using the 'date'
SQLite3 function, which produces rows in the '2006-01-02' format. This
patch adds a special case so that these rows can be extracted without
error.
Individual tests were never successfully removing 'foo.db' (the error was ignored), which caused everything but the first test to fail on my vmhgfs filesystem. Adding the relevant defer db.Close() and rows.Close() calls fixed the leaks, enabling os.Remove() to work.
Original:
--- FAIL: TestInsert (0.00 seconds)
sqlite3_test.go:42: Failed to create table:%!(EXTRA *errors.errorString=unable to open database file)
With corrections:
--- FAIL: TestInsert (0.00 seconds)
sqlite3_test.go:42: Failed to create table: unable to open database file