-
-
Notifications
You must be signed in to change notification settings - Fork 753
♻️ Use mysql's default string length for mariadb #882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I realize now that it might be worth mentioning that the reason I wanted the default value was because setting the |
Damn, so I just ran into this issue when I've executed This is really sad since - if I get it right - this will stop me from using sqlmodel in my current project and switch back to sqlalchemy :(. Thanks for your PR. |
Any estimation when this will be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general!
@itsbekas, thanks for working on this!
Could you please take a look at my comments?
fake = FakeMetadata() | ||
fake.max_length = getattr(meta, "max_length", None) | ||
return fake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that this is not needed anymore.
In current version max_length
is already used as VARCHAR length (with both Pydantic V1 and V2)
if impl.length is None and ( | ||
dialect.name == "mysql" or dialect.name == "mariadb" | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if impl.length is None and ( | |
dialect.name == "mysql" or dialect.name == "mariadb" | |
): | |
if impl.length is None and dialect.name in ("mysql", "mariadb"): |
A bit more compact and easier to read
As I presented in #881 , mariadb doesn't have a default string size, unlike mysql, which leads to an sqlalchemy compile error. From what I understood (and tried), simply using the mysql default length and checking for the mariadb dialect.name is enough to prevent this error.