-
Notifications
You must be signed in to change notification settings - Fork 254
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
Fixed omission of 'collation' keyword in existing CHAR type #286
base: master
Are you sure you want to change the base?
Conversation
…codegen into render_column_type
for more information, see https://pre-commit.ci
…codegen into render_column_type
I do wonder if this problem is specific to only a single column type? I'm not very fond of special casing |
A better solution would be inspecting the types and checking which parameters need to be keyword arguments. |
in my DB setup, almost all kinds are there and when I tried it, all types other than |
Rather than special casing specific types, it would be best to detect this automatically so it's more future proof. Plus there could be obscure vendor specific types that also need this treatment. |
maybe there was a problem with importing multiple times among them, the In SQLAlchemy# sqlalchemy/sql/sqltypes.py
...
class String(Concatenable, TypeEngine[str]):
"""The base for all string and character types.
In SQL, corresponds to VARCHAR.
The `length` field is usually required when the `String` type is
used within a CREATE TABLE statement, as VARCHAR requires a length
on most databases.
"""
__visit_name__ = "string"
def __init__(
self,
length: Optional[int] = None,
collation: Optional[str] = None,
):
...
...
class CHAR(String):
"""The SQL CHAR type."""
__visit_name__ = "CHAR" # sqlalchemy/dialects/mysql/types.py
...
class CHAR(_StringType, sqltypes.CHAR):
"""MySQL CHAR type, for fixed-length character data."""
__visit_name__ = "CHAR"
def __init__(self, length=None, **kwargs):
... Generated filefrom sqlalchemy import CHAR ...
from sqlalchemy.dialects.mysql import CHAR ...
... |
How is it importing two different CHARs? Are the column types on the DB side different somehow? |
Just dropping in, having tried 3.0.0rc5 against our MySQL schema.
One of our students had a bash at fixing sqlacodegen v2 here: https://github.com/wtsi-npg/sqlacodegen/tree/additional-patches , but the big sqlalchemy v2 upheaval made that moot. |
Fixes #285 Error in Generated SQLAlchemy Model for CHAR Column