Conversation
|
codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
| files_modified = 0 | ||
| functions_modified = 0 | ||
|
|
||
| print("\nStarting SQLAlchemy 1.6 to 2.0 migration...") |
There was a problem hiding this comment.
maybe this type of logging can happen as part of the function wrapper in the CLI.
| # Step 3: Convert Column Definitions to Type Annotations | ||
| for cls in file.classes: | ||
| for attr in cls.attributes: | ||
| if "Column(" in attr.source: |
There was a problem hiding this comment.
might want to make sure Column( is the beginning of the assignment
| if "Column(" in attr.source: | ||
| original_attr = attr.source | ||
| new_attr = original_attr.replace("Column", "mapped_column") | ||
| type_hint = "Mapped" + original_attr.split("= Column")[1] |
There was a problem hiding this comment.
I'm confused by this here.
a = Column(Integer) should become
a: Mapped[int] = mapped_column()
I'm actually not sure what this new type hint would be based on this logic..
a: Mapped[(Integer)] ?
| chain = chain.parent | ||
|
|
||
| original_code = chain.source | ||
| new_query = chain.source.replace("query(", "select(") |
There was a problem hiding this comment.
sqlalchemy 2.0 conventions are to use from sqlalchemy import select for everything right?
Wasn't 1.6 syntax more like
Model.query.filter()
session.query(Model)
and both of these should change to
session.scalars(select(Model).where(...))
or session.scalar(select(Modle).where(...))
and in cases where you're not querying the whole ORM object it would have to be
session.execute(select(Model.a, Model.b))
i believe filter_by is still valid too on the new select
No description provided.