aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert-Jan Timmer <gjr.timmer@gmail.com>2018-05-29 11:58:29 +0200
committerGert-Jan Timmer <gjr.timmer@gmail.com>2018-05-29 11:58:29 +0200
commitafd179bd93c5ef77cc8d4695a02341b4bd85584f (patch)
tree9b1187309014281e9cdb8f98870c7e1e6143f7d3
parentUpdate Busy Timeout PRAGMA (diff)
downloadgolite-afd179bd93c5ef77cc8d4695a02341b4bd85584f.tar.gz
golite-afd179bd93c5ef77cc8d4695a02341b4bd85584f.tar.xz
Update Foreign Keys PRAGMA
ADD: Multiple key
-rw-r--r--README.md2
-rw-r--r--sqlite3.go13
2 files changed, 10 insertions, 5 deletions
diff --git a/README.md b/README.md
index e890c0d..eec00d8 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,7 @@ Boolean values can be one of:
| Auto Vacuum | `_vacuum` | <ul><li>`0` \| `none`</li><li>`1` \| `full`</li><li>`2` \| `incremental`</li></ul> | For more information see [PRAGMA auto_vacuum](https://www.sqlite.org/pragma.html#pragma_auto_vacuum) |
| Busy Timeout | `_busy_timeout` \| `_timeout` | `int` | Specify value for sqlite3_busy_timeout. For more information see [PRAGMA busy_timeout](https://www.sqlite.org/pragma.html#pragma_busy_timeout) |
| Case Sensitive LIKE | `_cslike` | `boolean` | For more information see [PRAGMA case_sensitive_like](https://www.sqlite.org/pragma.html#pragma_case_sensitive_like) |
-| Foreign Keys | `_foreign_keys` | `boolean` | For more information see [PRAGMA foreign_keys](https://www.sqlite.org/pragma.html#pragma_foreign_keys) |
+| Foreign Keys | `_foreign_keys` \| `_fk` | `boolean` | For more information see [PRAGMA foreign_keys](https://www.sqlite.org/pragma.html#pragma_foreign_keys) |
| Mutex Locking | `_mutex` | <ul><li>no</li><li>full</li></ul> | Specify mutex mode. |
| Recursive Triggers | `_recursive_triggers` | `boolean` | For more information see [PRAGMA recursive_triggers](https://www.sqlite.org/pragma.html#pragma_recursive_triggers) |
| Shared-Cache Mode | `cache` | <ul><li>shared</li><li>private</li></ul> | Set cache mode for more information see [sqlite.org](https://www.sqlite.org/sharedcache.html) |
diff --git a/sqlite3.go b/sqlite3.go
index aa45559..d009358 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -803,14 +803,14 @@ func errorString(err Error) string {
// Specify locking behavior for transactions. XXX can be "immediate",
// "deferred", "exclusive".
//
-// _busy_timeout=XXX
+// _busy_timeout=XXX"| _timeout=XXX
// Specify value for sqlite3_busy_timeout.
//
// _cslike=Boolean
// Default or disabled the LIKE operation is case-insensitive.
// When enabling this options behaviour of LIKE will become case-sensitive.
//
-// _foreign_keys=Boolean
+// _foreign_keys=Boolean | _fk=Boolean
// Enable or disable enforcement of foreign keys. X can be 1 or 0.
//
// _recursive_triggers=Boolean
@@ -938,8 +938,13 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
//
// https://www.sqlite.org/pragma.html#pragma_foreign_keys
//
-
- if val := params.Get("_foreign_keys"); val != "" {
+ if _, ok := params["_foreign_keys"]; ok {
+ pkey = "_foreign_keys"
+ }
+ if _, ok := params["_fk"]; ok {
+ pkey = "_fk"
+ }
+ if val := params.Get(pkey); val != "" {
switch strings.ToLower(val) {
case "0", "no", "false", "off":
foreignKeys = 0