Skip to content

refactor(predicates & generator): scope nullability operators, optimize array serialization, and enhance array migration support - #81

Merged
VoidClancy merged 5 commits into
masterfrom
scalar-arrays-non-nullable-required-fields-the-name-is-too-long
Jul 31, 2026
Merged

refactor(predicates & generator): scope nullability operators, optimize array serialization, and enhance array migration support#81
VoidClancy merged 5 commits into
masterfrom
scalar-arrays-non-nullable-required-fields-the-name-is-too-long

Conversation

@VoidClancy

Copy link
Copy Markdown
Owner

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

…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
@VoidClancy VoidClancy self-assigned this Jul 31, 2026
@VoidClancy
VoidClancy merged commit 555fb55 into master Jul 31, 2026
11 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