Description
Describe the feature
With strict tables, SQLite can enforce data type integrity that is not enforced otherwise. Without strict tables, the following works in SQLite:
CREATE TABLE user(id INTEGER);
INSERT into user VALUES ("YOLO!"); --- This works!
Is it possible to enable strict tables in Gorm, somehow? I've tried to do db.Set("gorm:table_options", "STRICT")
, but it seemingly has no effect. To inspect whether the table has been created strict, I run the following query:
select * from pragma_table_list
And if the strict
column is set to 1
, it's a strict table. So far, I've not been successful in having Gorm create strict tables in SQLite. Do I need to create a custom SQLite Dialector
for this?
Motivation
Strict tables enable data integrity checks that are disabled by default.
Sorry for cross-posting this to go-gorm/gorm#7443, but I'm unsure whether this is a feature that belongs to Gorm or the SQLite driver/dialector.