refactor(predicates & generator): scope nullability operators, optimize array serialization, and enhance array migration support - #81
Merged
VoidClancy merged 5 commits intoJul 31, 2026
Conversation
…pport in migration dialects
1- Add support for scalar lists (arrays) in postgresDialect and sqliteDialect to generate accurate SQL types (text[], TEXT) and array default values ('{}', '[]') during migrations
2- Add buildJsonArrayCheckConstraints() to convertToAtlasSchema to generate json_valid() check constraints for SQLite JSON array columns
3- Update prepareSchema.js to convert scalar array fields to Json with /// @ElementType doc comments for SQLite
…and enforce compile-time safety 1- Remove IsNull() and IsNotNull() from non-optional base predicate types (Field, UniqueField, StringField, StringUniqueField, ArrayField) so required fields cannot be queried for nullability at compile time 2- Add OptionalField, OptionalUniqueField, OptionalStringField, and OptionalStringUniqueField struct wrappers that embed base predicate types and exclusively expose IsNull() and IsNotNull() for optional schema fields
…abstraction, and @updatedat handling 1- Make lib/pq and database/sql/driver imports conditional in header.gotpl and runtime.gotpl, ensuring lib/pq is only imported when provider is postgres AND array fields exist 2- Update ArrayVal and ArrayScan to use pure Go json.Marshal/json.Unmarshal for SQLite and other providers while preserving pq.Array for PostgreSQL 3- Add RequiresConflictTarget boolean configuration to Dialect struct and refactor BuildConflictClause to remove string-based dialect comparisons 4- Consolidate repetitive type checking helpers in generator/helpers.go into generic hasType and hasModelType helpers, and replace imperative Need... default loops in generator.go with hasDefaultFunc 5- Fix pointer vs value assignments for @updatedat timestamp fields during model creation and updates
…ma for @updatedat and array fields 1- Add integration test suite in integration/predicate_operators_test.go verifying IsNull/IsNotNull predicate scoping and Has/HasEvery/HasSome/IsEmpty array operators 2- Update integration/schema.prisma and migrations with updatedAt, updatedAtNoDefualt, updatedAtnoDecorator, updatedAtOptional, and tags fields to verify default, required, optional, and @updatedat decorator behavior
…t abstraction, and @updatedat handling, adding scalar list and JSON check constraint support in migration dialects, and scoping nullability operators
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- Remove IsNull() and IsNotNull() from non-optional base predicate types (Field, UniqueField, StringField, StringUniqueField, ArrayField) so required fields cannot be queried for nullability at compile-time
2- Add OptionalField, OptionalUniqueField, OptionalStringField, and OptionalStringUniqueField struct wrappers that embed base predicate types and exclusively expose IsNull() and IsNotNull() for optional schema fields
3- Make lib/pq and database/sql/driver imports conditional in header.gotpl and runtime.gotpl, ensuring lib/pq is only imported when provider is postgres AND array fields exist
4- Update ArrayVal and ArrayScan to use pure Go json.Marshal/json.Unmarshal for SQLite and other providers while preserving pq.Array for PostgreSQL
5- Add RequiresConflictTarget boolean configuration to Dialect struct and refactor BuildConflictClause to remove string-based dialect comparisons
6- Consolidate repetitive type checking helpers in generator/helpers.go into generic hasType and hasModelType helpers, and replace imperative NeedFIELD() default loops in generator with hasDefaultFunc
7- Add support for scalar lists (arrays) in postgresDialect and sqliteDialect to generate accurate SQL types and array default values during migrations
8- Add buildJsonArrayCheckConstraints() to convertToAtlasSchema to generate json_valid() check constraints for SQLite JSON array columns
9- Add integration test suite for predicate operators verifying IsNull/IsNotNull predicate scoping and Has/HasEvery/HasSome/IsEmpty array operators
10 - Add support for @updatedat on create & update operations (IDK if i mentioned this i'm losing my mind)
11- Add updatedAt, updatedAtNoDefualt, updatedAtnoDecorator, and updatedAtOptional fields to User model to test default, required,optional, and decorator behavior, as it was generating wrong code for optional fields