Skip to content

Commit afd179b

Browse files
committed
Update Foreign Keys PRAGMA
ADD: Multiple key
1 parent f087cd7 commit afd179b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Boolean values can be one of:
7777
| 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) |
7878
| 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) |
7979
| Case Sensitive LIKE | `_cslike` | `boolean` | For more information see [PRAGMA case_sensitive_like](https://www.sqlite.org/pragma.html#pragma_case_sensitive_like) |
80-
| Foreign Keys | `_foreign_keys` | `boolean` | For more information see [PRAGMA foreign_keys](https://www.sqlite.org/pragma.html#pragma_foreign_keys) |
80+
| Foreign Keys | `_foreign_keys` \| `_fk` | `boolean` | For more information see [PRAGMA foreign_keys](https://www.sqlite.org/pragma.html#pragma_foreign_keys) |
8181
| Mutex Locking | `_mutex` | <ul><li>no</li><li>full</li></ul> | Specify mutex mode. |
8282
| Recursive Triggers | `_recursive_triggers` | `boolean` | For more information see [PRAGMA recursive_triggers](https://www.sqlite.org/pragma.html#pragma_recursive_triggers) |
8383
| 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) |

sqlite3.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,14 +803,14 @@ func errorString(err Error) string {
803803
// Specify locking behavior for transactions. XXX can be "immediate",
804804
// "deferred", "exclusive".
805805
//
806-
// _busy_timeout=XXX
806+
// _busy_timeout=XXX"| _timeout=XXX
807807
// Specify value for sqlite3_busy_timeout.
808808
//
809809
// _cslike=Boolean
810810
// Default or disabled the LIKE operation is case-insensitive.
811811
// When enabling this options behaviour of LIKE will become case-sensitive.
812812
//
813-
// _foreign_keys=Boolean
813+
// _foreign_keys=Boolean | _fk=Boolean
814814
// Enable or disable enforcement of foreign keys. X can be 1 or 0.
815815
//
816816
// _recursive_triggers=Boolean
@@ -938,8 +938,13 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
938938
//
939939
// https://www.sqlite.org/pragma.html#pragma_foreign_keys
940940
//
941-
942-
if val := params.Get("_foreign_keys"); val != "" {
941+
if _, ok := params["_foreign_keys"]; ok {
942+
pkey = "_foreign_keys"
943+
}
944+
if _, ok := params["_fk"]; ok {
945+
pkey = "_fk"
946+
}
947+
if val := params.Get(pkey); val != "" {
943948
switch strings.ToLower(val) {
944949
case "0", "no", "false", "off":
945950
foreignKeys = 0

0 commit comments

Comments
 (0)