Previously, the timezone information for a provided value was discarded
and the value always stored as in UTC. However, sqlite allows specifying
the timezone offsets and handles those values appropriately. This change
stores the timezone information and parses it out if present, otherwise
it defaults to UTC as before.
One additional bugfix: Previously, a unix timestamp in seconds was
parsed in the local timezone (rather than UTC), in contrast to a unix
timestamp in milliseconds that was parsed in UTC.
While fixing that extra bug, I cleaned up the parsing code -- no need to
convert to a string and then parse it back again and risk a parse error,
just to check the number of digits.
The tests were extended to cover non-UTC timezones storage & retrieval,
meaningful unix timestamps, and correct handling of a trailing Z.
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.