feat(codegen): add PostgreSQL schema support and fix custom primary-key generation#10
Merged
Conversation
Add dialect-aware code generation with a PostgreSQL path in the codegen entrypoint. Extend SQL parsing, type mapping, and primary key handling for a documented minimal PostgreSQL subset while keeping MySQL coverage under tests. Update repository generation to use parsed primary key names and types instead of hard-coded id assumptions; risk is limited to the supported PostgreSQL scope.
Document the postgres dialect flag, supported scope, and current limitations in the codegen README files. Add a runnable PostgreSQL sample schema so users can verify the new dialect path locally. Record follow-up TODO items for generated output snippets and future PostgreSQL coverage such as COMMENT ON and array types.
…e-level PK typing Update model codegen to return a typed zero value in Create() error paths instead of numeric literal 0. Recompute field Go type and IDType when a table-level PRIMARY KEY marks a previously nullable column as non-null. Add regression tests for PostgreSQL UUID/string primary keys and table-level PK declarations without explicit NOT NULL to prevent compile/type regressions.
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.
Summary
Add PostgreSQL support to code generation and fix primary-key handling for custom/non-numeric IDs.
Changes
Createerror return to use typed zero values for dynamic ID types.PRIMARY KEY (...)marks a field non-null.NOT NULL.Testing
Impact