Skip to content

Auto decode basemodels into json fields#101

Merged
piercefreeman merged 2 commits intomainfrom
feature/nested-basemodels
Mar 26, 2026
Merged

Auto decode basemodels into json fields#101
piercefreeman merged 2 commits intomainfrom
feature/nested-basemodels

Conversation

@piercefreeman
Copy link
Copy Markdown
Owner

@piercefreeman piercefreeman commented Mar 26, 2026

While it's usually better to use foreign keys to associate database level data, there are some cases where you want to throw convention out the window and embed basemodels directly as json within your table. The email-confirmation payload in mountaineer-cloud is one of those cases.

This PR adds ergonomic handling for this situations. If you annotate a column with a regular BaseModel and indicate is_json=True (to make explicit that it will be embedded versus potentially getting confused as a foreign key relation), we will automatically serialize and deserialize it into the proper model during the round trip to the database.

@piercefreeman piercefreeman merged commit 508c2ed into main Mar 26, 2026
6 checks passed
@piercefreeman piercefreeman deleted the feature/nested-basemodels branch March 26, 2026 21:11
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