You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't create UNIQUE constraints with column name ofgroup in sqlite #4407
I've created a table with a column, named group, and there's a UNIQUE constraint on it. It works on postgres, but will fail on sqlite. The SQL statement is
CREATETABLEIF NOT EXISTS `Requests` (`id`INTEGERPRIMARY KEY AUTOINCREMENT, `group`INTEGERNOT NULLREFERENCES`Groups` (`id`) ON DELETE CASCADEONUPDATE CASCADE, `license`INTEGERNOT NULLREFERENCES`Licenses` (`id`) ON DELETE CASCADEONUPDATE CASCADE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (group, license));
However the correct SQL should be as below, which needs column names in UNIQUE to be quoted.
CREATETABLEIF NOT EXISTS `Requests` (`id`INTEGERPRIMARY KEY AUTOINCREMENT, `group`INTEGERNOT NULLREFERENCES`Groups` (`id`) ON DELETE CASCADEONUPDATE CASCADE, `license`INTEGERNOT NULLREFERENCES`Licenses` (`id`) ON DELETE CASCADEONUPDATE CASCADE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`group`, `license`));
Activity
Add quotes around column names for unique constraints in sqlite (sequ…
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …
Add quotes around column names for unique constraints in sqlite (fixes …