SQLite strict tables

Aperta
#204 0 commenti 4 reazioni 1 assegnatario Vedi su GitHub

@jinzhu ci sta già lavorando.

Dal 3/5/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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!

@anthonywritescode has a watchworthy video about this. 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 https://github.com/go-gorm/gorm/discussions/7443, but I'm unsure whether this is a feature that belongs to Gorm or the SQLite driver/dialector.

Lingua principale
Go
Stelle
235
Fork
217
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di go-gorm/sqlite

Tutte le issue di go-gorm/sqlite

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.