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
06540138
Commit
06540138
authored
Feb 21, 2017
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go 1.8: ColumnTypeScanType, ColumnTypeDatabaseTypeName
Still missing: StmtExecContext and StmtQueryContext
parent
e2dd408b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
driver.go
driver.go
+72
-0
No files found.
driver.go
View file @
06540138
...
...
@@ -153,6 +153,34 @@ func (c *conn) Prepare(query string) (driver.Stmt, error) {
return
&
stmt
{
s
:
s
},
nil
}
func
(
c
*
conn
)
PrepareContext
(
ctx
context
.
Context
,
query
string
)
(
driver
.
Stmt
,
error
)
{
return
c
.
Prepare
(
query
)
}
/*func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
if c.c.IsClosed() {
return nil, driver.ErrBadConn
}
s, err := c.c.Prepare(query)
if err != nil {
return nil, err
}
st := stmt{s: s}
return st.QueryContext(ctx, args)
}
func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
if c.c.IsClosed() {
return nil, driver.ErrBadConn
}
s, err := c.c.Prepare(query)
if err != nil {
return nil, err
}
st := stmt{s: s}
return st.ExecContext(ctx, args)
}*/
func
(
c
*
conn
)
Close
()
error
{
return
c
.
c
.
Close
()
}
...
...
@@ -232,6 +260,27 @@ func (s *stmt) Query(args []driver.Value) (driver.Rows, error) {
return
&
rowsImpl
{
s
,
nil
},
nil
}
/*func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
panic("TBD")
}
func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
panic("TBD")
}
func progressHandler(p interface{}) bool {
if ctx, ok := p.(context.Context); ok {
select {
case <-ctx.Done():
// Cancelled
return true
default:
return false
}
}
return false
}*/
func
(
s
*
stmt
)
bind
(
args
[]
driver
.
Value
)
error
{
for
i
,
v
:=
range
args
{
if
err
:=
s
.
s
.
BindByIndex
(
i
+
1
,
v
);
err
!=
nil
{
...
...
@@ -273,6 +322,29 @@ func (r *rowsImpl) Close() error {
return
r
.
s
.
s
.
Reset
()
}
// TODO HasNextResultSet && Stmt.tail ?
func
(
r
*
rowsImpl
)
ColumnTypeScanType
(
index
int
)
reflect
.
Type
{
switch
r
.
s
.
s
.
ColumnType
(
index
)
{
case
Integer
:
return
reflect
.
TypeOf
(
int64
(
0
))
case
Float
:
return
reflect
.
TypeOf
(
float64
(
0
))
case
Text
:
return
reflect
.
TypeOf
(
""
)
case
Null
:
return
reflect
.
TypeOf
(
nil
)
case
Blob
:
fallthrough
default
:
return
reflect
.
TypeOf
([]
byte
{})
}
}
func
(
r
*
rowsImpl
)
ColumnTypeDatabaseTypeName
(
index
int
)
string
{
return
r
.
s
.
s
.
ColumnDeclaredType
(
index
)
}
func
(
c
*
Conn
)
result
()
driver
.
Result
{
// TODO How to know that the last Stmt has done an INSERT? An authorizer?
id
:=
c
.
LastInsertRowid
()
...
...
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