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
28b88271
Commit
28b88271
authored
Aug 11, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to SQLITE_DBCONFIG_ENABLE_TRIGGER.
parent
1d4f09bb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
sqlite.go
sqlite.go
+19
-3
sqlite_test.go
sqlite_test.go
+10
-0
No files found.
sqlite.go
View file @
28b88271
...
...
@@ -247,7 +247,7 @@ func (c *Conn) BusyTimeout(ms int) error { // TODO time.Duration ?
//
// (See http://sqlite.org/c3ref/c_dbconfig_enable_fkey.html)
func
(
c
*
Conn
)
EnableFKey
(
b
bool
)
(
bool
,
error
)
{
return
c
.
queryOrSetEnable
FKey
(
btocint
(
b
))
return
c
.
queryOrSetEnable
DbConfig
(
C
.
SQLITE_DBCONFIG_ENABLE_FKEY
,
btocint
(
b
))
}
// Calls sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_FKEY, -1)
...
...
@@ -255,9 +255,25 @@ func (c *Conn) EnableFKey(b bool) (bool, error) {
//
// (See http://sqlite.org/c3ref/c_dbconfig_enable_fkey.html)
func
(
c
*
Conn
)
IsFKeyEnabled
()
(
bool
,
error
)
{
return
c
.
queryOrSetEnable
FKey
(
-
1
)
return
c
.
queryOrSetEnable
DbConfig
(
C
.
SQLITE_DBCONFIG_ENABLE_FKEY
,
-
1
)
}
func
(
c
*
Conn
)
queryOrSetEnableFKey
(
i
C
.
int
)
(
bool
,
error
)
{
// Enable or disable triggers
// Calls sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_TRIGGER, b)
//
// (See http://sqlite.org/c3ref/c_dbconfig_enable_fkey.html)
func
(
c
*
Conn
)
EnableTriggers
(
b
bool
)
(
bool
,
error
)
{
return
c
.
queryOrSetEnableDbConfig
(
C
.
SQLITE_DBCONFIG_ENABLE_TRIGGER
,
btocint
(
b
))
}
// Calls sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_TRIGGER, -1)
//
// (See http://sqlite.org/c3ref/c_dbconfig_enable_fkey.html)
func
(
c
*
Conn
)
AreTriggersEnabled
()
(
bool
,
error
)
{
return
c
.
queryOrSetEnableDbConfig
(
C
.
SQLITE_DBCONFIG_ENABLE_TRIGGER
,
-
1
)
}
func
(
c
*
Conn
)
queryOrSetEnableDbConfig
(
key
,
i
C
.
int
)
(
bool
,
error
)
{
var
ok
C
.
int
rv
:=
C
.
my_db_config
(
c
.
db
,
C
.
SQLITE_DBCONFIG_ENABLE_FKEY
,
i
,
&
ok
)
if
rv
==
C
.
SQLITE_OK
{
...
...
sqlite_test.go
View file @
28b88271
...
...
@@ -56,6 +56,16 @@ func TestEnableFKey(t *testing.T) {
}
}
func
TestEnableTriggers
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
db
.
Close
()
b
:=
Must
(
db
.
AreTriggersEnabled
())
if
!
b
{
b
=
Must
(
db
.
EnableTriggers
(
true
))
assert
(
t
,
"cannot enabled triggers"
,
b
)
}
}
func
TestEnableExtendedResultCodes
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
db
.
Close
()
...
...
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