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
288d5a3f
Commit
288d5a3f
authored
Mar 22, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce checkStep in tests.
parent
d8830656
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
61 deletions
+39
-61
function_test.go
function_test.go
+3
-9
meta.go
meta.go
+4
-0
sqlite_test.go
sqlite_test.go
+2
-4
stmt_test.go
stmt_test.go
+30
-48
No files found.
function_test.go
View file @
288d5a3f
...
@@ -79,25 +79,19 @@ func TestRegexpFunction(t *testing.T) {
...
@@ -79,25 +79,19 @@ func TestRegexpFunction(t *testing.T) {
checkNoError
(
t
,
err
,
"couldn't prepare statement: %s"
)
checkNoError
(
t
,
err
,
"couldn't prepare statement: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
b
:=
Must
(
s
.
Next
());
!
b
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatalf
(
"No result"
)
}
i
,
_
,
err
:=
s
.
ScanInt
(
0
)
i
,
_
,
err
:=
s
.
ScanInt
(
0
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
assert
.
Equal
(
t
,
1
,
i
)
assert
.
Equal
(
t
,
1
,
i
)
assert
.
T
(
t
,
!
reused
,
"unexpected reused state"
)
assert
.
T
(
t
,
!
reused
,
"unexpected reused state"
)
if
b
:=
Must
(
s
.
Next
());
!
b
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatalf
(
"No result"
)
}
i
,
_
,
err
=
s
.
ScanInt
(
0
)
i
,
_
,
err
=
s
.
ScanInt
(
0
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
assert
.
Equal
(
t
,
0
,
i
)
assert
.
Equal
(
t
,
0
,
i
)
assert
.
T
(
t
,
reused
,
"unexpected reused state"
)
assert
.
T
(
t
,
reused
,
"unexpected reused state"
)
if
b
:=
Must
(
s
.
Next
());
!
b
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatalf
(
"No result"
)
}
i
,
_
,
err
=
s
.
ScanInt
(
0
)
i
,
_
,
err
=
s
.
ScanInt
(
0
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
checkNoError
(
t
,
err
,
"couldn't scan result: %s"
)
assert
.
Equal
(
t
,
0
,
i
)
assert
.
Equal
(
t
,
0
,
i
)
...
...
meta.go
View file @
288d5a3f
...
@@ -140,6 +140,7 @@ type Column struct {
...
@@ -140,6 +140,7 @@ type Column struct {
// Columns returns a description for each column in the named table/view.
// Columns returns a description for each column in the named table/view.
// Column.Autoinc and Column.CollSeq are left unspecified.
// Column.Autoinc and Column.CollSeq are left unspecified.
// No error is returned if the table does not exist.
// (See http://www.sqlite.org/pragma.html#pragma_table_info)
// (See http://www.sqlite.org/pragma.html#pragma_table_info)
func
(
c
*
Conn
)
Columns
(
dbName
,
table
string
)
([]
Column
,
error
)
{
func
(
c
*
Conn
)
Columns
(
dbName
,
table
string
)
([]
Column
,
error
)
{
var
pragma
string
var
pragma
string
...
@@ -280,6 +281,7 @@ type ForeignKey struct {
...
@@ -280,6 +281,7 @@ type ForeignKey struct {
}
}
// ForeignKeys returns one description for each foreign key that references a column in the argument table.
// ForeignKeys returns one description for each foreign key that references a column in the argument table.
// No error is returned if the table does not exist.
// (See http://www.sqlite.org/pragma.html#pragma_foreign_key_list)
// (See http://www.sqlite.org/pragma.html#pragma_foreign_key_list)
func
(
c
*
Conn
)
ForeignKeys
(
dbName
,
table
string
)
(
map
[
int
]
*
ForeignKey
,
error
)
{
func
(
c
*
Conn
)
ForeignKeys
(
dbName
,
table
string
)
(
map
[
int
]
*
ForeignKey
,
error
)
{
var
pragma
string
var
pragma
string
...
@@ -324,6 +326,7 @@ type Index struct {
...
@@ -324,6 +326,7 @@ type Index struct {
}
}
// TableIndexes returns one description for each index associated with the given table.
// TableIndexes returns one description for each index associated with the given table.
// No error is returned if the table does not exist.
// (See http://www.sqlite.org/pragma.html#pragma_index_list)
// (See http://www.sqlite.org/pragma.html#pragma_index_list)
func
(
c
*
Conn
)
TableIndexes
(
dbName
,
table
string
)
([]
Index
,
error
)
{
func
(
c
*
Conn
)
TableIndexes
(
dbName
,
table
string
)
([]
Index
,
error
)
{
var
pragma
string
var
pragma
string
...
@@ -354,6 +357,7 @@ func (c *Conn) TableIndexes(dbName, table string) ([]Index, error) {
...
@@ -354,6 +357,7 @@ func (c *Conn) TableIndexes(dbName, table string) ([]Index, error) {
// IndexColumns returns one description for each column in the named index.
// IndexColumns returns one description for each column in the named index.
// Only Column.Cid and Column.Name are specified. All other fields are unspecified.
// Only Column.Cid and Column.Name are specified. All other fields are unspecified.
// No error is returned if the index does not exist.
// (See http://www.sqlite.org/pragma.html#pragma_index_info)
// (See http://www.sqlite.org/pragma.html#pragma_index_info)
func
(
c
*
Conn
)
IndexColumns
(
dbName
,
index
string
)
([]
Column
,
error
)
{
func
(
c
*
Conn
)
IndexColumns
(
dbName
,
index
string
)
([]
Column
,
error
)
{
var
pragma
string
var
pragma
string
...
...
sqlite_test.go
View file @
288d5a3f
...
@@ -149,14 +149,12 @@ func TestInsert(t *testing.T) {
...
@@ -149,14 +149,12 @@ func TestInsert(t *testing.T) {
columnCount
:=
cs
.
ColumnCount
()
columnCount
:=
cs
.
ColumnCount
()
assert
.
Equal
(
t
,
1
,
columnCount
,
"column count"
)
assert
.
Equal
(
t
,
1
,
columnCount
,
"column count"
)
if
!
Must
(
cs
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
cs
))
t
.
Fatal
(
"no result for count"
)
}
assert
.
Equal
(
t
,
columnCount
,
cs
.
DataCount
(),
"column & data count expected to be equal"
)
assert
.
Equal
(
t
,
columnCount
,
cs
.
DataCount
(),
"column & data count expected to be equal"
)
var
i
int
var
i
int
checkNoError
(
t
,
cs
.
Scan
(
&
i
),
"error scanning count: %s"
)
checkNoError
(
t
,
cs
.
Scan
(
&
i
),
"error scanning count: %s"
)
assert
.
Equal
(
t
,
1000
,
i
,
"count"
)
assert
.
Equal
(
t
,
1000
,
i
,
"count"
)
if
Must
(
cs
.
Next
()
)
{
if
checkStep
(
t
,
cs
)
{
t
.
Fatal
(
"Only one row expected"
)
t
.
Fatal
(
"Only one row expected"
)
}
}
assert
.
T
(
t
,
!
cs
.
Busy
(),
"expected statement to be reset"
)
assert
.
T
(
t
,
!
cs
.
Busy
(),
"expected statement to be reset"
)
...
...
stmt_test.go
View file @
288d5a3f
...
@@ -5,9 +5,12 @@
...
@@ -5,9 +5,12 @@
package
sqlite_test
package
sqlite_test
import
(
import
(
"fmt"
"math"
"math"
"os"
"os"
"path"
"reflect"
"reflect"
"runtime"
"testing"
"testing"
"time"
"time"
"unsafe"
"unsafe"
...
@@ -20,6 +23,15 @@ func checkFinalize(s *Stmt, t *testing.T) {
...
@@ -20,6 +23,15 @@ func checkFinalize(s *Stmt, t *testing.T) {
checkNoError
(
t
,
s
.
Finalize
(),
"Error finalizing statement: %s"
)
checkNoError
(
t
,
s
.
Finalize
(),
"Error finalizing statement: %s"
)
}
}
func
checkStep
(
t
*
testing
.
T
,
s
*
Stmt
)
bool
{
b
,
err
:=
s
.
Next
()
if
err
!=
nil
{
_
,
file
,
line
,
_
:=
runtime
.
Caller
(
1
)
t
.
Fatalf
(
"
\n
%s:%d: %s"
,
path
.
Base
(
file
),
line
,
fmt
.
Sprintf
(
"step error: %s"
,
err
))
}
return
b
}
func
TestInsertWithStatement
(
t
*
testing
.
T
)
{
func
TestInsertWithStatement
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
defer
checkClose
(
db
,
t
)
...
@@ -57,9 +69,7 @@ func TestInsertWithStatement(t *testing.T) {
...
@@ -57,9 +69,7 @@ func TestInsertWithStatement(t *testing.T) {
cs
,
_
:=
db
.
Prepare
(
"SELECT COUNT(*) FROM test"
)
cs
,
_
:=
db
.
Prepare
(
"SELECT COUNT(*) FROM test"
)
defer
checkFinalize
(
cs
,
t
)
defer
checkFinalize
(
cs
,
t
)
assert
.
T
(
t
,
cs
.
ReadOnly
(),
"SELECT statement should be readonly"
)
assert
.
T
(
t
,
cs
.
ReadOnly
(),
"SELECT statement should be readonly"
)
if
!
Must
(
cs
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
cs
))
t
.
Fatal
(
"no result for count"
)
}
var
i
int
var
i
int
checkNoError
(
t
,
cs
.
Scan
(
&
i
),
"error scanning count: %s"
)
checkNoError
(
t
,
cs
.
Scan
(
&
i
),
"error scanning count: %s"
)
assert
.
Equal
(
t
,
1000
,
i
,
"count"
)
assert
.
Equal
(
t
,
1000
,
i
,
"count"
)
...
@@ -71,7 +81,7 @@ func TestInsertWithStatement(t *testing.T) {
...
@@ -71,7 +81,7 @@ func TestInsertWithStatement(t *testing.T) {
secondColumnName
:=
rs
.
ColumnName
(
1
)
secondColumnName
:=
rs
.
ColumnName
(
1
)
assert
.
Equal
(
t
,
"int_num"
,
secondColumnName
,
"column name"
)
assert
.
Equal
(
t
,
"int_num"
,
secondColumnName
,
"column name"
)
if
Must
(
rs
.
Next
()
)
{
if
checkStep
(
t
,
rs
)
{
var
fnum
float64
var
fnum
float64
var
inum
int64
var
inum
int64
var
sstr
string
var
sstr
string
...
@@ -80,7 +90,7 @@ func TestInsertWithStatement(t *testing.T) {
...
@@ -80,7 +90,7 @@ func TestInsertWithStatement(t *testing.T) {
assert
.
Equal
(
t
,
int64
(
0
),
inum
)
assert
.
Equal
(
t
,
int64
(
0
),
inum
)
assert
.
Equal
(
t
,
"hello"
,
sstr
)
assert
.
Equal
(
t
,
"hello"
,
sstr
)
}
}
if
Must
(
rs
.
Next
()
)
{
if
checkStep
(
t
,
rs
)
{
var
fnum
float64
var
fnum
float64
var
inum
int64
var
inum
int64
var
sstr
string
var
sstr
string
...
@@ -101,9 +111,7 @@ func TestScanColumn(t *testing.T) {
...
@@ -101,9 +111,7 @@ func TestScanColumn(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 1, null, 0"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1, null, 0"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
i1
,
i2
,
i3
int
var
i1
,
i2
,
i3
int
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
i1
))
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
i1
))
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
...
@@ -127,9 +135,7 @@ func TestNamedScanColumn(t *testing.T) {
...
@@ -127,9 +135,7 @@ func TestNamedScanColumn(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 1 AS i1, null AS i2, 0 AS i3"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1 AS i1, null AS i2, 0 AS i3"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
i1
,
i2
,
i3
int
var
i1
,
i2
,
i3
int
null
:=
Must
(
s
.
ScanByName
(
"i1"
,
&
i1
))
null
:=
Must
(
s
.
ScanByName
(
"i1"
,
&
i1
))
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
...
@@ -161,9 +167,7 @@ func TestScanCheck(t *testing.T) {
...
@@ -161,9 +167,7 @@ func TestScanCheck(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 'hello'"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 'hello'"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
i
int
var
i
int
_
,
err
=
s
.
ScanByIndex
(
0
,
&
i
)
_
,
err
=
s
.
ScanByIndex
(
0
,
&
i
)
if
serr
,
ok
:=
err
.
(
*
StmtError
);
ok
{
if
serr
,
ok
:=
err
.
(
*
StmtError
);
ok
{
...
@@ -182,9 +186,7 @@ func TestScanNull(t *testing.T) {
...
@@ -182,9 +186,7 @@ func TestScanNull(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT null"
)
s
,
err
:=
db
.
Prepare
(
"SELECT null"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
pi
=
new
(
int
)
var
pi
=
new
(
int
)
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
pi
))
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
pi
))
assert
.
T
(
t
,
null
,
"expected null value"
)
assert
.
T
(
t
,
null
,
"expected null value"
)
...
@@ -232,9 +234,7 @@ func TestScanNotNull(t *testing.T) {
...
@@ -232,9 +234,7 @@ func TestScanNotNull(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 1"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
pi
=
new
(
int
)
var
pi
=
new
(
int
)
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
pi
))
null
:=
Must
(
s
.
ScanByIndex
(
0
,
&
pi
))
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
assert
.
T
(
t
,
!
null
,
"expected not null value"
)
...
@@ -263,9 +263,7 @@ func TestScanError(t *testing.T) {
...
@@ -263,9 +263,7 @@ func TestScanError(t *testing.T) {
s, err := db.Prepare("SELECT 1")
s, err := db.Prepare("SELECT 1")
checkNoError(t, err, "prepare error: %s")
checkNoError(t, err, "prepare error: %s")
defer checkFinalize(s, t)
defer checkFinalize(s, t)
if !Must(s.Next()) {
assert.T(t, checkStep(t, s))
t.Fatal("no result")
}
var pi *int
var pi *int
null, err := s.ScanByIndex(0, &pi)
null, err := s.ScanByIndex(0, &pi)
t.Errorf("(%t,%s)", null, err)
t.Errorf("(%t,%s)", null, err)
...
@@ -407,8 +405,7 @@ func TestNamedBind(t *testing.T) {
...
@@ -407,8 +405,7 @@ func TestNamedBind(t *testing.T) {
var
byt
byte
=
'!'
var
byt
byte
=
'!'
err
=
is
.
NamedBind
(
":b"
,
byt
,
":blob"
,
blob
)
err
=
is
.
NamedBind
(
":b"
,
byt
,
":blob"
,
blob
)
checkNoError
(
t
,
err
,
"named bind error: %s"
)
checkNoError
(
t
,
err
,
"named bind error: %s"
)
_
,
err
=
is
.
Next
()
checkStep
(
t
,
is
)
checkNoError
(
t
,
err
,
"named bind step error: %s"
)
err
=
is
.
NamedBind
(
":b"
,
byt
,
":invalid"
,
nil
)
err
=
is
.
NamedBind
(
":b"
,
byt
,
":invalid"
,
nil
)
assert
.
T
(
t
,
err
!=
nil
,
"invalid param name expected"
)
assert
.
T
(
t
,
err
!=
nil
,
"invalid param name expected"
)
...
@@ -423,9 +420,7 @@ func TestNamedBind(t *testing.T) {
...
@@ -423,9 +420,7 @@ func TestNamedBind(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT data AS bs, byte AS b FROM test"
)
s
,
err
:=
db
.
Prepare
(
"SELECT data AS bs, byte AS b FROM test"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
bs
[]
byte
var
bs
[]
byte
var
b
byte
var
b
byte
err
=
s
.
NamedScan
(
"b"
,
&
b
,
"bs"
,
&
bs
)
err
=
s
.
NamedScan
(
"b"
,
&
b
,
"bs"
,
&
bs
)
...
@@ -450,8 +445,7 @@ func TestBind(t *testing.T) {
...
@@ -450,8 +445,7 @@ func TestBind(t *testing.T) {
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
err
=
is
.
Bind
(
nil
,
true
)
err
=
is
.
Bind
(
nil
,
true
)
checkNoError
(
t
,
err
,
"bind error: %s"
)
checkNoError
(
t
,
err
,
"bind error: %s"
)
_
,
err
=
is
.
Next
()
checkStep
(
t
,
is
)
checkNoError
(
t
,
err
,
"step error: %s"
)
err
=
is
.
Bind
(
int32
(
1
),
float32
(
273.1
))
err
=
is
.
Bind
(
int32
(
1
),
float32
(
273.1
))
checkNoError
(
t
,
err
,
"bind error: %s"
)
checkNoError
(
t
,
err
,
"bind error: %s"
)
...
@@ -490,9 +484,7 @@ func TestScanValues(t *testing.T) {
...
@@ -490,9 +484,7 @@ func TestScanValues(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 1, null, 0"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1, null, 0"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
values
:=
make
([]
interface
{},
3
)
values
:=
make
([]
interface
{},
3
)
s
.
ScanValues
(
values
)
s
.
ScanValues
(
values
)
assert
.
Equal
(
t
,
int64
(
1
),
values
[
0
])
assert
.
Equal
(
t
,
int64
(
1
),
values
[
0
])
...
@@ -507,9 +499,7 @@ func TestScanBytes(t *testing.T) {
...
@@ -507,9 +499,7 @@ func TestScanBytes(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 'test'"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 'test'"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
blob
,
_
:=
s
.
ScanBlob
(
0
)
blob
,
_
:=
s
.
ScanBlob
(
0
)
assert
.
Equal
(
t
,
"test"
,
string
(
blob
))
assert
.
Equal
(
t
,
"test"
,
string
(
blob
))
}
}
...
@@ -522,9 +512,7 @@ func TestBindEmptyZero(t *testing.T) {
...
@@ -522,9 +512,7 @@ func TestBindEmptyZero(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT ?, ?"
,
""
,
zero
)
s
,
err
:=
db
.
Prepare
(
"SELECT ?, ?"
,
""
,
zero
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
ps
*
string
var
ps
*
string
var
zt
time
.
Time
var
zt
time
.
Time
...
@@ -552,9 +540,7 @@ func TestBindEmptyZeroNotTransformedToNull(t *testing.T) {
...
@@ -552,9 +540,7 @@ func TestBindEmptyZeroNotTransformedToNull(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT ?, ?"
,
""
,
zero
)
s
,
err
:=
db
.
Prepare
(
"SELECT ?, ?"
,
""
,
zero
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
assert
.
T
(
t
,
checkStep
(
t
,
s
))
t
.
Fatal
(
"no result"
)
}
var
st
string
var
st
string
var
zt
time
.
Time
var
zt
time
.
Time
...
@@ -628,9 +614,7 @@ func TestBindAndScanReflect(t *testing.T) {
...
@@ -628,9 +614,7 @@ func TestBindAndScanReflect(t *testing.T) {
s
,
err
:=
db
.
Prepare
(
"SELECT 1"
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
defer
checkFinalize
(
s
,
t
)
ok
,
err
:=
s
.
Next
()
assert
.
T
(
t
,
checkStep
(
t
,
s
))
checkNoError
(
t
,
err
,
"step error: %s"
)
assert
.
T
(
t
,
ok
)
is
,
err
:=
db
.
Prepare
(
"SELECT ?"
)
is
,
err
:=
db
.
Prepare
(
"SELECT ?"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
...
@@ -680,9 +664,7 @@ func TestBindAndScanReflect(t *testing.T) {
...
@@ -680,9 +664,7 @@ func TestBindAndScanReflect(t *testing.T) {
checkNoError
(
t
,
is
.
BindReflect
(
1
,
amount
),
"bind error: %s"
)
checkNoError
(
t
,
is
.
BindReflect
(
1
,
amount
),
"bind error: %s"
)
checkNoError
(
t
,
is
.
BindReflect
(
1
,
-
1
),
"bind error: %s"
)
checkNoError
(
t
,
is
.
BindReflect
(
1
,
-
1
),
"bind error: %s"
)
ok
,
err
=
is
.
Next
()
assert
.
T
(
t
,
checkStep
(
t
,
is
))
checkNoError
(
t
,
err
,
"step error: %s"
)
assert
.
T
(
t
,
ok
)
_
,
err
=
is
.
ScanReflect
(
0
,
&
enum
)
_
,
err
=
is
.
ScanReflect
(
0
,
&
enum
)
assert
.
T
(
t
,
err
!=
nil
)
assert
.
T
(
t
,
err
!=
nil
)
...
...
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