Lighter-swift / Lighter

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.
https://lighter-swift.github.io/documentation/lighter/
MIT License
459 stars 12 forks source link

Add a separate type for "integer pkeys" in SQLite3Schema #14

Closed helje5 closed 2 years ago

helje5 commented 2 years ago

Lighter currently considers all int pkeys as database generated, but that is only true if they are spelled explicitly as INTEGER (case doesn't matter). I.e. just id INT PRIMARY KEY doesn't actually work. We should replicate the SQLite behaviour and only consider a property as autogenerated if it matches the requirements.

This probably warrants a new type or marker in SQLite3Schema.

helje5 commented 2 years ago

Implemented, and seems to work fine. "INTEGER" and "INT" are now detected as separate schema types (but are both mapped to .integer properties).

Only "INTEGER" columns are setup with the autogenerated key behaviour (i.e. are ignored at INSERT time).