Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
f88e7c6c
Commit
f88e7c6c
authored
Feb 28, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to Time type in Bind methods.
Unix time has been choosen as default storage format.
parent
9c5a8b15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
date_test.go
date_test.go
+11
-0
sqlite.go
sqlite.go
+4
-4
No files found.
date_test.go
View file @
f88e7c6c
...
...
@@ -18,6 +18,17 @@ func TestJulianDay(t *testing.T) {
}
}
func
TestBind
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
db
.
Close
()
var
delta
int
err
:=
db
.
OneValue
(
"SELECT CAST(strftime('%s', 'now') AS NUMERIC) - ?"
,
&
delta
,
time
.
Now
())
checkNoError
(
t
,
err
,
"Error reading date: %#v"
)
if
delta
!=
0
{
t
.
Errorf
(
"Delta between Go and SQLite timestamps: %d"
,
delta
)
}
}
func
TestScan
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
db
.
Close
()
...
...
sqlite.go
View file @
f88e7c6c
...
...
@@ -691,10 +691,10 @@ func (s *Stmt) BindByIndex(index int, value interface{}) error {
p
=
&
value
[
0
]
}
rv
=
C
.
my_bind_blob
(
s
.
stmt
,
i
,
unsafe
.
Pointer
(
p
),
C
.
int
(
len
(
value
)))
/*
case time.Time: // At least three representations are possible: string (YYYY-MM-DDTHH:MM:SS.SSS), int64 (unix time), float64 (julian day
)
rv = C.sqlite3_bind_text(
)
*/
case
time
.
Time
:
// At least three representations are possible: string (YYYY-MM-DD HH:MM:SS.SSS), int64 (unix time), float64 (julian day)
// rv = C.my_bind_text(s.stmt, i, value.format("2006-01-02 15:04:05.000")
)
rv
=
C
.
sqlite3_bind_int64
(
s
.
stmt
,
i
,
C
.
sqlite3_int64
(
value
.
Unix
())
)
// rv = C.sqlite3_bind_double(s.stmt, i, JulianDay(value))
case
ZeroBlobLength
:
rv
=
C
.
sqlite3_bind_zeroblob
(
s
.
stmt
,
i
,
C
.
int
(
value
))
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment