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
0b0ed9e5
Commit
0b0ed9e5
authored
Nov 28, 2013
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Conn.Exec.
parent
e67326dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
sqlite.go
sqlite.go
+10
-8
sqlite_test.go
sqlite_test.go
+10
-0
No files found.
sqlite.go
View file @
0b0ed9e5
...
...
@@ -322,21 +322,23 @@ func (c *Conn) Exec(cmd string, args ...interface{}) error {
cmd
=
s
.
tail
continue
}
err
=
s
.
Exec
(
args
...
)
var
subargs
[]
interface
{}
count
:=
s
.
BindParameterCount
()
if
len
(
s
.
tail
)
>
0
&&
len
(
args
)
>=
count
{
subargs
=
args
[
:
count
]
args
=
args
[
count
:
]
}
else
{
subargs
=
args
}
err
=
s
.
Exec
(
subargs
...
)
if
err
!=
nil
{
s
.
finalize
()
return
err
}
if
len
(
s
.
tail
)
>
0
{
if
len
(
args
)
>
0
{
s
.
finalize
()
return
c
.
specificError
(
"cannot execute multiple statements when args are specified: %q"
,
cmd
)
}
}
cmd
=
s
.
tail
if
err
=
s
.
finalize
();
err
!=
nil
{
return
err
}
cmd
=
s
.
tail
}
return
nil
}
...
...
sqlite_test.go
View file @
0b0ed9e5
...
...
@@ -247,6 +247,16 @@ func TestExecMisuse(t *testing.T) {
//println(err.Error())
}
func
TestExecTwice
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
createTable
(
db
,
t
)
err
:=
db
.
Exec
(
"INSERT INTO test VALUES (?, ?, ?, ?); INSERT INTO test VALUES (?, ?, ?, ?)"
,
0
,
273.1
,
1
,
"test"
,
1
,
2257
,
2
,
nil
)
checkNoError
(
t
,
err
,
"Exec error: %s"
)
}
func
TestTransaction
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
...
...
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