Use _foreign_keys=1 instead of _fk=1
authorCyril Brulebois <cyril@debamax.com>
Fri, 8 Jan 2021 17:27:15 +0000 (17:27 +0000)
committerCyril Brulebois <cyril@debamax.com>
Mon, 3 May 2021 07:29:06 +0000 (08:29 +0100)
The _foreign_keys=1 syntax is widely supported but the _fk=1 alias for
it was only added in version 1.8.0 of the sqlite3 driver. Avoid using
the alias for the time being (the freeze is near).

Gbp-Pq: Name 0002-add-compatibility-for-older-sqlite-driver.patch

pkg/database/database.go

index 2daef7c69ced728cbcc92de50b0454f1b18103a7..ccc9d928739cf5368f32de44678362aaff5a5cd1 100644 (file)
@@ -46,7 +46,7 @@ func NewClient(config *csconfig.DatabaseCfg) (*Client, error) {
                                return &Client{}, fmt.Errorf("unable to set perms on %s: %v", config.DbPath, err)
                        }
                }
-               client, err = ent.Open("sqlite3", fmt.Sprintf("file:%s?_busy_timeout=100000&_fk=1", config.DbPath))
+               client, err = ent.Open("sqlite3", fmt.Sprintf("file:%s?_busy_timeout=100000&_foreign_keys=1", config.DbPath))
                if err != nil {
                        return &Client{}, fmt.Errorf("failed opening connection to sqlite: %v", err)
                }