Skip to content

Chore: refactor the create struct-based API to be function based for consistency with the reads - #25

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

Chore: refactor the create struct-based API to be function based for consistency with the reads#25
VoidClancy merged 1 commit into
masterfrom
codegen

Conversation

@VoidClancy

@VoidClancy VoidClancy commented Jul 9, 2026

Copy link
Copy Markdown
Owner

1- define FieldAssignment (col+val) and RecordInput (slice of FieldAssignment) in header template

2- add .Set() on FieldT, UniqueFieldT, StringField, StringUniqueField in client template, field vars produce FieldAssignments

3- drop per-field SetFieldName() from model_predicate template, replaced by generic Set()

4- refactor create builders M,I,S,O to M,S,O, I param is dead (and we killed him), since it's the same slice of FieldAssignment every time, now it lives on the struct itself

5- add per-model validateCreate() that iterates the assignment slice, checks required/string-safety/enum-range per field

6- add assignmentsToModelCreate converter, from []FieldAssignment to ModelCreate struct, falls naturally with the beforeCreate Hook that takes the same struct and allows mutuation

7- rebuild executeModelCreate to accept []FieldAssignment instead of ModelCreate, converts to struct internally for hooks, validates original assignments, reads mutated struct fields for cols/vals

8- add Record() helper on delegates, wraps []FieldAssignment into RecordInput for CreateMany

9- add trimPrefix to template FuncMap, strips (*) from GoType for type assertions on optional/defaulted fields

10- update integration tests to use the new function-based API

11- fix @default(autoincrement()) skip col when nil instead of leaving val slot empty, caught during test run

12- add doc comments on Queries delegate fields listing Create fields with types/constraints for hover DX

14- add enum doc comments on const values and namespace struct fields showing DB mapping on hover

…consistency with the reads

1- define FieldAssignment (col+val) and RecordInput (slice of FieldAssignment) in header template

2- add .Set() on FieldT, UniqueFieldT, StringField, StringUniqueField in client template, field vars produce FieldAssignments

3- drop per-field SetFieldName() from model_predicate template, replaced by generic Set()

4- refactor create builders M,I,S,O to  M,S,O, I param dead (and we killed him), since it's the same slice of FieldAssignment every time, now it lives on the struct itself

5- add per-model validateCreate() that iterates the assignment slice, checks required/string-safety/enum-range per field

6- add assignmentsToModelCreate converter, from []FieldAssignment to ModelCreate struct, falls naturally with the beforeCreate Hook that takes the same struct and allows mutuation

7- rebuild executeModelCreate to accept []FieldAssignment instead of ModelCreate, converts to struct internally for hooks, validates original assignments, reads mutated struct fields for cols/vals

8- add Record() helper on delegates, wraps []FieldAssignment into RecordInput for CreateMany

9- add trimPrefix to template FuncMap, strips (*) from GoType for type assertions on optional/defaulted fields

10- update integration tests to use the new function-based API

11- fix @default(autoincrement()) skip col when nil instead of leaving val slot empty, caught during test run

12- add doc comments on Queries delegate fields listing Create fields with types/constraints for hover DX

14- add enum doc comments on const values and namespace struct fields showing DB mapping on hover
@VoidClancy VoidClancy self-assigned this Jul 9, 2026
@gitguardian

gitguardian Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
34685193 Triggered Generic Password 85d0232 integration/main.go View secret
34685192 Triggered Generic Password 85d0232 integration/main.go View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@VoidClancy
VoidClancy merged commit 81d0d72 into master Jul 9, 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