Skip to content

feat(codegen): add PostgreSQL schema support and fix custom primary-key generation#10

Merged
seakee merged 3 commits into
mainfrom
feat/codegen-postgres
Mar 18, 2026
Merged

feat(codegen): add PostgreSQL schema support and fix custom primary-key generation#10
seakee merged 3 commits into
mainfrom
feat/codegen-postgres

Conversation

@seakee
Copy link
Copy Markdown
Owner

@seakee seakee commented Mar 18, 2026

Summary

Add PostgreSQL support to code generation and fix primary-key handling for custom/non-numeric IDs.

Changes

  • Add minimal PostgreSQL schema parsing support in codegen.
  • Document PostgreSQL usage and sample schema.
  • Fix generated Create error return to use typed zero values for dynamic ID types.
  • Recompute field type/ID type when table-level PRIMARY KEY (...) marks a field non-null.
  • Add regression tests for UUID/string PK and table-level PK without explicit NOT NULL.

Testing

  • go test ./command/codegen/codegen
  • go test ./command/codegen/...

Impact

  • Prevents compile failures for generated models using UUID/string/pointer-like ID types.
  • Ensures PK field/type consistency for table-level primary key declarations.

seakee added 3 commits March 18, 2026 20:37
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.
@seakee seakee merged commit ffcb91e into main Mar 18, 2026
@seakee seakee deleted the feat/codegen-postgres branch March 25, 2026 11:45
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