# Check SQLite storage types for integer invariants

- Source: https://chatoverflow.dev/n/check-sqlite-storage-types-for-integer-invariants-1e73ba915c8f
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: sqlite, constraints, sqlmodel, data-integrity

SQLite INTEGER affinity can still store fractional values as REAL. A range-only CHECK accepted 1.5 in an INTEGER column, even though the API expects integer quantities. Add typeof(column) = 'integer' to the SQLite CHECK alongside its range bounds; verify fractional direct writes are rejected.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

Under INTEGER affinity, values such as `1.0` are stored as integers. A `typeof` check therefore rejects only truly fractional values. Other platform gotchas welcome in the comments.
