![]() ![]() The PRAGMA foreignkeys command is a no-op in this configuration. Is there no other way? Also not quite sure how that would work with CI. If SQLITEOMITTRIGGER is defined but SQLITEOMITFOREIGNKEY is not, then SQLite behaves as it did prior to version 3.6.19 () - foreign key definitions are parsed and may be queried using PRAGMA foreignkeylist, but foreign key constraints are not enforced. sqliterc file but it's a PITA to ask users to do that. Loading resources from /home/johnnyb/.sqlitercĮdit #2: I was able to get it to "stick" by adding the pragma to my. How do I set the foreign_keys pragma and make it stick?Įdit: riffing off the above, and leaving golang out of it: $ sqlite3 -init sqlite3-empty.sql I have also tried the URI based approach, found elsewhere: sqlite3, err := sql.Open("sqlite3", "file:unit_test.db?foreign_keys=on") Everything but the foreign_keys pragma works. Requests := strings.Split(string(file), " ")Įrr = fmt.Errorf("NewSQLite3() error executing seed file sql line: %v\n", err) ![]() Note that I am loading the sql creation script as part of a go unit test apparatus setup: sqlite3, err := sql.Open("sqlite3", "unit_test.db")Įrr = fmt.Errorf("NewSQLite3() error creating db connection: %w", err)įile, err := ioutil.ReadFile("sqlite3-empty.sql")Įrr = fmt.Errorf("NewSQLite3() error opening seed file: %w", err) sqliterc file? Or from an environment variable? A foreign key is a column or set of columns that references the parent key in the. Is there a away to set this pragma in my. Use foreign keys to enforce referential relationships between tables. Loading resources from /home/me/.sqliterc However, if I load the database file created by the sql file above, it doesn't stick: $ sqlite3 unit_test.db Loading resources from sqlite3-empty.sql When I load the sql file using -init it looks good: $ sqlite3 -init sqlite3-empty.sql In that sql file, I attempt to enforce foreign_keys with the pragma: PRAGMA foreign_keys = on - also 1, true ![]() I have created an SQL file that loads into sqlite3 and creates a bunch of tables for me. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |