Skip to content

feat: Accept plain strings for every enum-valued option. - #153

Merged
DanCardin merged 3 commits into
DanCardin:mainfrom
Dan-Knott:dk/accept-string-enum-options
Oct 28, 2026
Merged

DanCardin merged 3 commits into
DanCardin:mainfrom
Dan-Knott:dk/accept-string-enum-options

Conversation

@Dan-Knott

Copy link
Copy Markdown
Contributor

I've rebased all of the Enums for the functions and triggers on FromStrings and added __post_init__ to normalise them back to their enum values.

I decided to do the from_string conversion in __post_init__ so bad definitions fail at import instead of only coming up when being compared against the db.

Also added the missing with_volatility and with_parallel methods to the Postgres Function class.

Enum-valued options such as volatility='stable' were documented as accepted but failed when rendered, so every postgresql and mysql option now coerces strings in __post_init__. This also adds with_volatility and with_parallel to the postgresql Function.
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (111029c) to head (4080b4c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
+ Coverage   89.93%   90.26%   +0.33%     
==========================================
  Files          86       86              
  Lines        4151     4179      +28     
  Branches      861      861              
==========================================
+ Hits         3733     3772      +39     
+ Misses        338      329       -9     
+ Partials       80       78       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanCardin

Copy link
Copy Markdown
Owner

A drawback of using __post_init__ is that the api (and internal impl broadly) is very heavily dataclasses.replace based, so it'll get normalized a bunch of times repeatedly. It's not like its the worst thing in the world, but it's somewhat unfortunate.

@DanCardin

Copy link
Copy Markdown
Owner

with that said, 1. i'm not too worried about it and 2. it could probably be made more efficient (or at least not to unnecessarily perform the assignment) without breaking anything if it turns out to be a problem.

@DanCardin
DanCardin merged commit 91c5ca0 into DanCardin:main Oct 28, 2026
27 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.

2 participants