chore: Fix SQLite TIMESTAMP mapping, add catch-all type validation, refactor default func helpers#30
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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