feat: Add optional sqlalchemy_use_enum for dy.Enum#355
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds optional support for generating native SQLAlchemy ENUM types from dy.Enum columns (primarily for PostgreSQL / Alembic drift detection), plus accompanying docs and tests.
Changes:
- Extend
dy.Enumwithsqlalchemy_use_enumandsqlalchemy_enum_nameflags to emitsqlalchemy.Enuminstead ofCHAR/VARCHAR. - Add tests for SQLAlchemy column/type generation and for (de)serialization/matching behavior of the new flags.
- Document how to enable native SQL enums and how enum type names are chosen.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
dataframely/columns/enum.py |
Implements SQLAlchemy native enum mapping and naming rules. |
tests/columns/test_sqlalchemy_columns.py |
Verifies dialect-specific compilation/type naming and error behavior. |
tests/column_types/test_enum.py |
Validates matches() semantics + as_dict/from_dict for new flags. |
docs/guides/features/sql-generation.md |
Documents how to use the new native SQL enum feature. |
Andreas Albert (AndreasAlbertQC)
left a comment
There was a problem hiding this comment.
Thanks Jack Oberman (@jackoberman) ! I think the functionality is solid, I just have a few suggestions to improve readability / organization. Let me know if anything's not clear.
Allow dy.Enum to emit sqlalchemy.Enum for to_sqlalchemy_columns when sqlalchemy_use_enum=True, with optional sqlalchemy_enum_name and column- name defaults for PostgreSQL native enum types. Closes Quantco#354 Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58e0727 to
ba13eff
Compare
Andreas Albert (@AndreasAlbertQC) Thanks for the suggestions! I apologize it took me so long to respond. |
Andreas Albert (AndreasAlbertQC)
left a comment
There was a problem hiding this comment.
Thanks Jack Oberman (@jackoberman) ! Only super minor adjustments that I will just apply and then we are ready to go
Co-authored-by: Andreas Albert <103571926+AndreasAlbertQC@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 56 56
Lines 3463 3471 +8
=========================================
+ Hits 3463 3471 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Jack Oberman (@jackoberman) while playing with this, I realized (thanks copilot :)) that the pattern of storing the private Please take a look and let me know what you think :) |
This is much cleaner! Very nice! |
31a5b9e to
ad71405
Compare
Andreas Albert (AndreasAlbertQC)
left a comment
There was a problem hiding this comment.
Thanks Jack Oberman (@jackoberman) !
3089ece
into
Quantco:main
Allow dy.Enum to emit sqlalchemy.Enum for to_sqlalchemy_columns when sqlalchemy_use_enum=True, with optional sqlalchemy_enum_name and column- name defaults for PostgreSQL native enum types.
Closes #354