From afd179bd93c5ef77cc8d4695a02341b4bd85584f Mon Sep 17 00:00:00 2001 From: Gert-Jan Timmer Date: Tue, 29 May 2018 11:58:29 +0200 Subject: [PATCH] Update Foreign Keys PRAGMA ADD: Multiple key --- README.md | 2 +- sqlite3.go | 13 +++++++++---- 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` | | 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` | | 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` | | 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