Skip to content

chore: Fix SQLite TIMESTAMP mapping, add catch-all type validation, refactor default func helpers#30

Merged
VoidClancy merged 1 commit into
masterfrom
codegen
Jul 10, 2026
Merged

chore: Fix SQLite TIMESTAMP mapping, add catch-all type validation, refactor default func helpers#30
VoidClancy merged 1 commit into
masterfrom
codegen

Conversation

@VoidClancy

Copy link
Copy Markdown
Owner

1- Fix critical Sqlite dialect bug: TIMESTAMP columns no longer mapped to TEXT in migrations, previous mapping caused modernc/sqlite to treat timestamp columns as TEXT, breaking time.Time scan. Now TIMESTAMP correctly maps to TIMESTAMP so the driver auto-scans strings as time.Time

2- Add _time_format=sqlite DSN parameter to integration's main.go SQLite connection string

  • Add missing catch-all type validation in validate{Model}Create template (model_create.gotpl). Non-string/non-int scalar types (time.Time, bool, float64, json.RawMessage, []byte) now get Go type-assertion validation via the template fallback else branch using trimPrefix

3- Add isKnownDefaultFunc() and defaultFuncCall() helpers to generator's FuncMap, to be used by ToRowMap and cols/vals builder in model_create template instead of deep else-if chains per function. Adding a new default function only requires updating the map in generator.go

4- Add createdAt DateTime @default(now()) to Profile schema and regenerate generated client files to reflect the new field

… default func helpers

- Fix critical SQLite dialect bug: TIMESTAMP columns no longer mapped to TEXT in migration/sqliteDialect.go. Previous mapping caused modernc/sqlite to treat timestamp columns as TEXT, breaking time.Time scan. Now TIMESTAMP correctly maps to "TIMESTAMP" so the driver auto-scans strings as time.Time.

- Add _time_format=sqlite DSN parameter to integration/main.go SQLite connection string for consistent time serialization.

- Add missing catch-all type validation in validate{Model}Create template (model_create.gotpl). Non-string/non-int scalar types (time.Time, bool, float64, json.RawMessage, []byte) now get Go type-assertion validation via the template fallback else branch using trimPrefix.

- Add isKnownDefaultFunc() and defaultFuncCall() to generator.go FuncMap. ToRowMap and cols/vals builder in model_create.gotpl use these helpers instead of deep else-if chains per function. Adding a new default function only requires updating the two maps in generator.go.

- Add createdAt DateTime @default(now()) to Profile schema and regenerate generated client files to reflect the new field.
@VoidClancy VoidClancy self-assigned this Jul 10, 2026
@VoidClancy VoidClancy merged commit b6be00c into master Jul 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant