Commit Graph

137 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto 15491aeb9c go vet && golint 2016-11-06 13:16:38 +09:00
Yasuhiro Matsumoto 57eaf4c070 separate test 2016-11-04 15:17:21 +09:00
Yasuhiro Matsumoto b23526fb3c support named params 2016-11-04 15:00:29 +09:00
Yasuhiro Matsumoto 6796d46c3a implement go18 Pinger 2016-11-03 23:05:34 +09:00
Yasuhiro Matsumoto 3fb7a0e792 TestAggregatorRegistration may fail if trace feature is not implemented 2016-09-08 01:20:43 +09:00
yoza caab59fb66 Fix testing message at TestInsert and TestUpdate 2016-03-14 20:54:10 +09:00
Zac Medico 4f5821ada6 Test SQLiteRows.DeclTypes() 2016-03-07 01:15:24 -08:00
Lars Buitinck 21637a6531 Clean up tempfiles in tests
"go test" leaves no more clutter in /tmp.
2015-11-03 13:52:28 +01:00
Yasuhiro Matsumoto a755cdc361 Merge branch 'master' of https://github.com/mattn/go-sqlite3 2015-11-02 11:56:57 +09:00
Yasuhiro Matsumoto 59f20de728 fix tests 2015-11-02 11:56:49 +09:00
Yasuhiro Matsumoto 167173a31f Merge branch 'pr/207' 2015-11-02 11:53:42 +09:00
Augusto Roman 7b0d180ce9 Store/retrieve timezones for time.Time values.
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.
2015-10-09 22:59:25 -07:00
mattn 0bb7f1c676 Merge pull request #229 from danderson/master
Implement support for calling Go functions from SQLite
2015-09-16 10:46:17 +09:00
David Anderson 26917df7a6 Implement support for aggregation functions implemented in Go. 2015-09-15 18:05:49 -07:00
mattn 296ddf7cd7 Fix test. Close #216
When one goroutine close db that opended as :memory:, session
will be lost. So another goroutine can't refer the last session.
goroutine .
2015-08-25 23:40:01 +09:00
David Anderson b037a61690 Add support for interface{} arguments in Go SQLite functions.
This enabled support for functions like Foo(a interface{}) and
Bar(a ...interface{}).
2015-08-21 17:12:18 -07:00
David Anderson 566f63a43a Implement support for variadic functions.
Currently, the variadic part must all be the same type, because there's
no "generic" arg converter.
2015-08-21 16:38:23 -07:00
David Anderson 122ddb16de Move argument converters to callback.go, and optimize return value handling.
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.
2015-08-21 16:37:45 -07:00
David Anderson cf8fa0af80 Implement support for passing Go functions as custom functions to SQLite.
Fixes #226.
2015-08-21 13:39:50 -07:00
Lars Buitinck 5674e19d05 Test read-only databases 2015-06-05 16:38:51 +02:00
Lars Buitinck a3efcea001 Clean up more tempfiles 2015-06-05 16:38:51 +02:00
Lars Buitinck cebbf42ff6 Get reliable tempfile names from ioutil.TempFile
Also makes them easier to spot (the tests tend to litter /tmp).
2015-06-05 16:38:51 +02:00
Yasuhiro Matsumoto f136f0c8dc Remove debug code 2015-04-15 16:27:00 +09:00
Yasuhiro Matsumoto dee1a37fe1 Z suffix should be no-op 2015-04-15 16:26:27 +09:00
mattn 5f64400729 Merge pull request #194 from hallyn/tximm.2
Add a txlock option when opening databases
2015-04-14 09:12:54 +09:00
Serge Hallyn f91a09fb50 Add a txlock option when opening databases (v2)
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>
2015-04-13 11:48:01 -05:00
Egon Elbre ac0129617f Fix NULs in text.
NUL character is a valid symbols in UTF8.

Fixes #195
2015-04-12 15:02:50 +03:00
mattn 07f9c9c30f Implement number-named parameters. Close #187 2015-03-24 00:46:49 +09:00
mattn ff38c8ec02 Revert a6c208564e 2015-03-22 04:29:14 +09:00
mattn c1abf95b38 Fix build 2015-03-22 03:16:35 +09:00
mattn d7dbb909ec Fix test 2015-03-22 02:39:28 +09:00
mattn a6c208564e Support $NNN-style named parameter. Close #187 2015-03-22 02:08:47 +09:00
Yasuhiro Matsumoto f40baee643 Fix test 2015-03-05 12:39:44 +09:00
Yasuhiro Matsumoto d463e8f1f9 Remove test dup 2015-03-05 12:32:06 +09:00
mix3 e48e0597ab Fix loc parsing 2015-03-05 11:06:33 +09:00
mix3 71712f0ba9 Add test 2015-03-05 10:36:47 +09:00
Yasuhiro Matsumoto 02f54e0263 Add test 2015-03-05 10:34:31 +09:00
mattn e273a1552e Fixed bug for loc parameter 2015-03-05 01:17:38 +09:00
Yasuhiro Matsumoto 4c5c4e5261 Add loc=XXX parameters to handle timezone 2015-03-04 22:49:17 +09:00
mattn a141177ca6 Fix test 2015-01-26 18:58:58 +09:00
mattn 6717138923 Fix test 2015-01-26 18:55:41 +09:00
mattn 5e6658a5c8 Add test for Version 2015-01-26 18:43:28 +09:00
Ian Bishop 0b05acc293 Handle 13 digit datetime values 2015-01-02 16:42:25 +10:00
Paweł Błaszczyk abf79dbdd5 Fix for sqlite3_test import. 2014-08-20 16:13:15 +02:00
mattn 6535341da9 Add one blank line for godoc 2014-08-18 17:00:59 +09:00
mattn 5e5d088a36 Add license header 2014-08-18 16:56:31 +09:00
mattn 07b39a049e Add TestStress 2014-07-16 17:44:23 +09:00
mattn 191ca24657 Rename 2014-07-04 10:25:27 +09:00
mattn ff8505c4ac Rename 2014-07-04 10:21:58 +09:00
mattn 5fb02bd99d Enable test for Queryer 2014-06-26 04:06:39 +09:00
mattn d9e7576acf Fix error on Execer. Close #124 2014-06-26 03:54:30 +09:00
Tim O'Brien a2f69308b3 Add benchmark tests. As used by other database/sql drivers. 2013-09-18 19:56:03 +12:00
David Hill 5b74e9ce72 add new test for WAL journal_mode 2013-09-12 11:38:11 -04:00
mattn 1ca536cf83 Disable Execer/Queryer until database/sql/driver implement QueryRow: #82 2013-09-12 10:46:35 +09:00
mattn d8f315ab83 Fixes test 2013-09-09 13:45:51 +09:00
mattn 77ebf39cf9 Fixes Execer/Queryer 2013-09-09 12:28:34 +09:00
mattn fc9f8cab24 Fixes test 2013-09-09 11:27:04 +09:00
mattn d4673cd31c Implements Execer 2013-09-09 10:44:44 +09:00
mattn 77c9648f4a Fixes test 2013-09-03 19:40:18 +09:00
mattn 6176b90b70 Add tests 2013-09-03 19:36:33 +09:00
Jochen Voss ff8e6729ce Start work on introducing machine-readable error codes.
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".
2013-08-13 21:45:05 +09:00
Graeme Connell 9c24784fe1 Use file in os.TempDir() for tests.
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.
2013-05-09 11:37:39 -06:00
Micah Stetson 44496728c2 Support more of the timestamp formats undestood by SQLite 2012-12-29 16:51:15 -08:00
Micah Stetson ce139f706b Support time values with nanosecond precision 2012-12-29 16:36:29 -08:00
Micah Stetson f65db67ea3 Refactor timestamp tests 2012-12-29 16:24:53 -08:00
Micah Stetson f6d10a2a58 Convert times to UTC before storage 2012-12-29 14:47:17 -08:00
Micah Stetson 58c4612c1e Fix #33 and #34 2012-12-29 14:20:27 -08:00
Dobrosław Żybort 430103cc9e Add support for extracting `2006-01-02 15:04:05.000` formatted datetime. 2012-11-29 13:26:24 +01:00
lye dcd44f5118 Add support for extracting 2006-01-02 formatted timestamps.
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.
2012-11-03 19:45:58 -05:00
mattn b9ff6f3fd3 'is' does not work in some older sqlite3. 2012-09-12 11:43:54 +09:00
cds 2a36f8cd42 Replace t.Error(); return statement pairs with single t.Fatal() 2012-09-11 10:13:11 -05:00
cds 40b65367c5 Added missing db.Close() and rows.Close() calls; fixes tests on vmhgfs filesystems.
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.
2012-09-11 09:23:21 -05:00
cds 54826d9585 Fix erroneous error message for sql.Open() 2012-09-11 08:41:45 -05:00
cds 3456489fa1 gofmt + fix erroneous t.Errorf("foo:", err) statements to t.Error("foo:", err) .
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
2012-09-11 08:35:53 -05:00
jander d869678d3c Update sqlite3_test.go 2012-05-27 00:13:36 +08:00
jander 2f4a8f3f2c Update sqlite3_test.go 2012-05-27 00:10:29 +08:00
jander ed17eae07a fix TestBoolean 2012-05-27 00:09:12 +08:00
jander 1bfaa5b7d2 add bool type test: TestBoolean 2012-05-25 23:16:03 +08:00
John Gallagher 3abc337b8e Handle time.Time values with "timestamp" columns. 2012-04-07 00:29:24 -04:00
John Gallagher e85c34cf5c Fix typo (Tailed -> Failed). 2012-04-06 22:46:11 -04:00
mattn 8cbe65c9c3 merged bradfitz's patch. thanks. 2012-02-20 16:14:49 +09:00
lye 275bdb282a Added additional testcase for boolean roundtrips
This test creates a simple table, inserts some dummy boolean values,
then pulls them back out to ensure they are marshalled correctly.
2012-02-06 22:56:36 +00:00
mattn 7c18f62cf1 fixed package name. 2012-01-25 09:23:44 +09:00
mattn f4359f417e gofix. 2011-12-07 20:40:45 +09:00
mattn fdbb364aba fix LastInsertId()/RowsAffected(). 2011-11-15 11:03:31 +09:00
mattn e36e29f33e fix test. 2011-11-15 10:41:43 +09:00
mattn 8c1b840c44 simple test. 2011-11-13 03:52:02 +09:00