Replies: 1 comment
-
I just had to discover that even overriding |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
# not related to specific code
Description
I have to deal with a database that regularly changes, but which imposes no constraints on the data in columns. The software is so badly designed, but there is nothing I can do about it. It's a Microsoft Access nightmare.
There are columns that are supposed to be integers, but the cells contain
0
andnull
interchangeably. Also, there are date columns that have bothnull
and1899-12-30 12:34:56
to indicate that there is no valid date stored.When slurping up those data into SQLModels, I'd love to normalise the data, i.e. turn
0
and the weird date intoNone
.But how?
Validation does not work when data come from the database because it is assumed that data in the database are proper. Well, not in this case.
With SQLAlchemy's voodoo magic replacing
__init__
on models, I could find no way to invoke code to run after a new instance was created and populated with data, but before it's returned to the user.Please don't make me have to provide proxy properties, or hack
__getattr__
. Why can't we just have a__post_init__
?Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.24
Python Version
3.13.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions