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
0d695f4e
Commit
0d695f4e
authored
Jun 03, 2014
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consider any value different from zero to be true.
parent
caa35353
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
5 deletions
+30
-5
function.go
function.go
+1
-1
meta_extra.go
meta_extra.go
+2
-2
stmt.go
stmt.go
+2
-2
stmt_test.go
stmt_test.go
+25
-0
No files found.
function.go
View file @
0d695f4e
...
@@ -287,7 +287,7 @@ func (c *ScalarContext) SetAuxData(n int, ad interface{}) {
...
@@ -287,7 +287,7 @@ func (c *ScalarContext) SetAuxData(n int, ad interface{}) {
// Bool obtains a SQL function parameter value.
// Bool obtains a SQL function parameter value.
// The leftmost value is number 0.
// The leftmost value is number 0.
func
(
c
*
FunctionContext
)
Bool
(
i
int
)
bool
{
func
(
c
*
FunctionContext
)
Bool
(
i
int
)
bool
{
return
c
.
Int
(
i
)
==
1
return
c
.
Int
(
i
)
!=
0
}
}
// Blob obtains a SQL function parameter value.
// Blob obtains a SQL function parameter value.
...
...
meta_extra.go
View file @
0d695f4e
...
@@ -38,8 +38,8 @@ func (c *Conn) Column(dbName, tableName, columnName string) (*Column, error) {
...
@@ -38,8 +38,8 @@ func (c *Conn) Column(dbName, tableName, columnName string) (*Column, error) {
if
rv
!=
C
.
SQLITE_OK
{
if
rv
!=
C
.
SQLITE_OK
{
return
nil
,
c
.
error
(
rv
,
fmt
.
Sprintf
(
"Conn.Column(db: %q, tbl: %q, col: %q)"
,
dbName
,
tableName
,
columnName
))
return
nil
,
c
.
error
(
rv
,
fmt
.
Sprintf
(
"Conn.Column(db: %q, tbl: %q, col: %q)"
,
dbName
,
tableName
,
columnName
))
}
}
return
&
Column
{
-
1
,
columnName
,
C
.
GoString
(
zDataType
),
notNull
==
1
,
""
,
int
(
primaryKey
),
return
&
Column
{
-
1
,
columnName
,
C
.
GoString
(
zDataType
),
notNull
!=
0
,
""
,
int
(
primaryKey
),
autoinc
==
1
,
C
.
GoString
(
zCollSeq
)},
nil
autoinc
!=
0
,
C
.
GoString
(
zCollSeq
)},
nil
}
}
// ColumnDatabaseName returns the database
// ColumnDatabaseName returns the database
...
...
stmt.go
View file @
0d695f4e
...
@@ -978,7 +978,7 @@ func (s *Stmt) ScanBool(index int) (value bool, isNull bool, err error) {
...
@@ -978,7 +978,7 @@ func (s *Stmt) ScanBool(index int) (value bool, isNull bool, err error) {
if
CheckTypeMismatch
{
if
CheckTypeMismatch
{
err
=
s
.
checkTypeMismatch
(
ctype
,
Integer
)
err
=
s
.
checkTypeMismatch
(
ctype
,
Integer
)
}
}
value
=
C
.
sqlite3_column_int
(
s
.
stmt
,
C
.
int
(
index
))
==
1
value
=
C
.
sqlite3_column_int
(
s
.
stmt
,
C
.
int
(
index
))
!=
0
}
}
return
return
}
}
...
@@ -1162,5 +1162,5 @@ func (s *Stmt) Conn() *Conn {
...
@@ -1162,5 +1162,5 @@ func (s *Stmt) Conn() *Conn {
// ReadOnly returns true if the prepared statement is guaranteed to not modify the database.
// ReadOnly returns true if the prepared statement is guaranteed to not modify the database.
// (See http://sqlite.org/c3ref/stmt_readonly.html)
// (See http://sqlite.org/c3ref/stmt_readonly.html)
func
(
s
*
Stmt
)
ReadOnly
()
bool
{
func
(
s
*
Stmt
)
ReadOnly
()
bool
{
return
C
.
sqlite3_stmt_readonly
(
s
.
stmt
)
==
1
return
C
.
sqlite3_stmt_readonly
(
s
.
stmt
)
!=
0
}
}
stmt_test.go
View file @
0d695f4e
...
@@ -749,3 +749,28 @@ func TestCheckTypeMismatch(t *testing.T) {
...
@@ -749,3 +749,28 @@ func TestCheckTypeMismatch(t *testing.T) {
assert
.
T
(
t
,
err
!=
nil
)
assert
.
T
(
t
,
err
!=
nil
)
//println(err.Error())
//println(err.Error())
}
}
func
TestReadOnly
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
s
,
err
:=
db
.
Prepare
(
"DROP TABLE IF EXISTS test"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
assert
.
T
(
t
,
s
.
ReadOnly
())
//checkNoError(t, s.Exec(), "exe error: %s")
checkFinalize
(
s
,
t
)
s
,
err
=
db
.
Prepare
(
"CREATE TABLE test (data TEXT)"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
assert
.
T
(
t
,
!
s
.
ReadOnly
())
checkNoError
(
t
,
s
.
Exec
(),
"exe error: %s"
)
checkFinalize
(
s
,
t
)
s
,
err
=
db
.
Prepare
(
"DROP TABLE IF EXISTS test"
)
//s, err = db.Prepare("DROP TABLE test")
checkNoError
(
t
,
err
,
"prepare error: %s"
)
assert
.
T
(
t
,
s
.
ReadOnly
())
// FIXME
checkNoError
(
t
,
s
.
Exec
(),
"exe error: %s"
)
checkFinalize
(
s
,
t
)
assert
.
T
(
t
,
!
s
.
ReadOnly
())
}
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