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
e3326449
Commit
e3326449
authored
May 04, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ScanTime such as it does not panic when column type affinity is wrong
parent
6d0e7451
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
stmt.go
stmt.go
+4
-3
No files found.
stmt.go
View file @
e3326449
...
...
@@ -531,7 +531,7 @@ var typeText = map[Type]string{
// After a type conversion, the value returned by sqlite3_column_type() is undefined.
// (See sqlite3_column_type: http://sqlite.org/c3ref/column_blob.html)
func
(
s
*
Stmt
)
ColumnType
(
index
int
)
Type
{
return
Type
(
C
.
sqlite3_column_type
(
s
.
stmt
,
C
.
int
(
index
)))
return
Type
(
C
.
sqlite3_column_type
(
s
.
stmt
,
C
.
int
(
index
)))
// TODO request all columns type at once
}
// NamedScan scans result values from a query by name (name1, value1, ...).
...
...
@@ -1031,7 +1031,8 @@ func (s *Stmt) ScanRawBytes(index int) (value []byte, isNull bool) {
// Returns true when column is null.
// The column type affinity must be consistent with the format used (INTEGER or NUMERIC or NONE for unix time, REAL or NONE for julian day).
func
(
s
*
Stmt
)
ScanTime
(
index
int
)
(
value
time
.
Time
,
isNull
bool
,
err
error
)
{
switch
s
.
ColumnType
(
index
)
{
ctype
:=
s
.
ColumnType
(
index
)
switch
ctype
{
case
Null
:
isNull
=
true
case
Text
:
// does not work as expected if column type affinity is TEXT but inserted value was a numeric
...
...
@@ -1080,7 +1081,7 @@ func (s *Stmt) ScanTime(index int) (value time.Time, isNull bool, err error) {
jd
:=
float64
(
C
.
sqlite3_column_double
(
s
.
stmt
,
C
.
int
(
index
)))
value
=
JulianDayToLocalTime
(
jd
)
// local time
default
:
panic
(
"The column type is not one of SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, or SQLITE_NULL"
)
s
.
specificError
(
"unexpected column type affinity for time persistence: %q"
,
ctype
)
}
return
}
...
...
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