Skip to content

Conversation

@RobbieMcKinstry
Copy link
Contributor

FEATURE: Add SQLModel code generation from PostgreSQL DDL schemas

Implements the Python code generator based on the design document at
crates/codegen/PYTHON_SQLMODEL_DESIGN.md. This generates SQLModel
class definitions from PostgreSQL table schemas with support for:

  • Type mapping: PostgreSQL to Python types (integers, floats, text,
    datetime, UUID, JSON, arrays, etc.)
  • Constraint support: Primary keys, foreign keys, unique constraints,
    check constraints, composite constraints
  • Name sanitization: Python reserved word handling with configurable
    strategies (append underscore or prepend prefix)
  • Output modes: Single file or multi-file generation
  • Docstrings: Optional table comment preservation as class docstrings
  • Identity columns: Proper handling with Optional type and default=None

Includes comprehensive test suite with 109 tests covering unit tests
for each module and snapshot tests for full generation output.

https://claude.ai/code/session_017z7szq6Jd5YPsRkdVDwu4q

FEATURE: Add SQLModel code generation from PostgreSQL DDL schemas

Implements the Python code generator based on the design document at
crates/codegen/PYTHON_SQLMODEL_DESIGN.md. This generates SQLModel
class definitions from PostgreSQL table schemas with support for:

- Type mapping: PostgreSQL to Python types (integers, floats, text,
  datetime, UUID, JSON, arrays, etc.)
- Constraint support: Primary keys, foreign keys, unique constraints,
  check constraints, composite constraints
- Name sanitization: Python reserved word handling with configurable
  strategies (append underscore or prepend prefix)
- Output modes: Single file or multi-file generation
- Docstrings: Optional table comment preservation as class docstrings
- Identity columns: Proper handling with Optional type and default=None

Includes comprehensive test suite with 109 tests covering unit tests
for each module and snapshot tests for full generation output.

https://claude.ai/code/session_017z7szq6Jd5YPsRkdVDwu4q
DOCS: Mark completed sections and identify future work

Updates the Python SQLModel code generator design document to reflect
the current implementation status. Adds status markers ([x] completed,
[ ] future work, [~] partial) throughout the document and consolidates
future enhancements into a single list.

Completed:
- Phases 1-5, 8: Core infrastructure, type mapping, naming, model
  generation, constraints, and testing
- All basic type mappings including arrays and JSONB
- Reserved word handling and identifier sanitization
- Single-file and multi-file output modes
- 109 unit tests and 11 snapshot tests

Future work:
- Relationship generation with back_populates
- Pydantic-only base models
- User-defined enum support
- Generated column support with Computed
- Single-column Field(index=True)
- default_factory for datetime defaults

https://claude.ai/code/session_017z7szq6Jd5YPsRkdVDwu4q
@RobbieMcKinstry RobbieMcKinstry merged commit 721a1a2 into trunk Jan 30, 2026
5 checks passed
@RobbieMcKinstry RobbieMcKinstry deleted the claude/implement-python-sqlmodel-codegen-0GpQP branch January 30, 2026 03:40
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.

2 participants