Skip to content

issue 1166 Update test to use SQLAlchemy 2.0 compatible select statement #1167

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

Merged
merged 9 commits into from
Mar 13, 2025
5 changes: 2 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,8 @@ class Temp(Base):

Session = sqlalchemy.orm.sessionmaker(engine)
with Session() as session:
pd.read_sql(
session.query(Temp.quantity).statement, session.connection()
)
stmt = sqlalchemy.select(Temp.quantity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are modifying the type of stmt so you are not really testing what used to be tested. What is needed is to update the stubs so that this test passes.
Without changing this test, what needs to be done is to update a pyi file.
For that I would recommend you look into what is the new type of stmt with the update of sqlalchemy, you will see that stmt has now an extra possible type UpdateBase and what how that impacts the stubs in pandas-stubs/io/sql.pyi. There you see that the Type Alias _SQLStatement is too restrictive and you need to allow UpdateBase in that TypeAlias too.
Feel free to let me know if something is unclear.

pd.read_sql(stmt, session.connection())


def test_sqlalchemy_text() -> None:
Expand Down