I'm wondering if this is how fields like max_length should work #746
Replies: 4 comments 5 replies
-
You can use sa_type argument Try this:
|
Beta Was this translation helpful? Give feedback.
-
I've just stumbled on this issue too. This was working as expected when targeting Pydantic V1, so think it is a bug. The I dug a little deeper and the issue appears to be in a function in
The configured max length is in field.metadata, but as an annotated type, not |
Beta Was this translation helpful? Give feedback.
-
I opened a small PR (#857) that seems to fix the issue by checking for the case mentioned above. |
Beta Was this translation helpful? Give feedback.
-
I am using a combination of max_length and sa_type
it seems to kinda work, but mypy is really mad about it:
in SQLModel the type for
|
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
I'm wondering if this is how fields like max_length should work.
Hi, if you look at the SQLModel class below, you can see that the maximum field length for
username
is set to 25.So I expected the SQL equivalent of this to be something like
VARCHAR(6)
, but the actual SQL doesn't add any constraints on the length to the VARCHAR.Should I use sa_column for this? Or is there another way and I'm missing something?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.14
Python Version
3.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions