schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

SQLAlchemy 2.0 Support #147

Closed michaelbukachi closed 2 years ago

michaelbukachi commented 2 years ago

Is your feature request related to a problem? Please describe. Hello, So we have been migrated most of the code to support SQAlchemy 2.0 syntax in preparation of its release. We have been using this guide.. In this step, we noticed quite a number of warnings were coming from pytest-mock-resources.

Describe the solution you'd like A clear and concise description of what you want to happen. I'm wondering if it's possible to have the full support of SQLAlchemy 2.0. I'm not sure if making it compatible will break changes in the older versions. Willing to do a PR for this.

Additional context Add any other context or screenshots about the feature request here. Below is a list of warnings thrown (there are only 2 actually):

  /home/michael/.cache/pypoetry/virtualenvs/app-d-AWDS2Y-py3.9/lib/python3.9/site-packages/pytest_mock_resources/fixture/database/relational/postgresql.py:99: RemovedIn20Warning: Passing a string to Connection.execute() is deprecated and will be removed in version 2.0.  Use the text() construct, or the Connection.exec_driver_sql() method to invoke a driver-level SQL string. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    conn.execute(

  /home/michael/.cache/pypoetry/virtualenvs/app-d-AWDS2Y-py3.9/lib/python3.9/site-packages/pytest_mock_resources/fixture/database/relational/postgresql.py:99: RemovedIn20Warning: The current statement is being autocommitted using implicit autocommit, which will be removed in SQLAlchemy 2.0. Use the .begin() method of Engine or Connection in order to use an explicit transaction for DML and DDL statements. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    conn.execute(
DanCardin commented 2 years ago

Yea :(, I'm aware of this, I just haven't had a chance to finish it off. A while back I made a (probably now stale) in progress branch to try to address. https://github.com/schireson/pytest-mock-resources/tree/dc/sqlalchemy2-warnings. Though admittedly the majority of the effort did seem to be in tests.

Seeing it impact someone else, I can try to push this along

michaelbukachi commented 2 years ago

Added it in my fork. I only touched the source code. I broke most of the tests though. Probably because of the wrong SQLAlchemy versions.

DanCardin commented 2 years ago

Would you mind testing this branch ^ to see if it addresses all the warnings you're hitting on your project?

DanCardin commented 2 years ago

not released yet, dont @ me github

michaelbukachi commented 2 years ago

Would you mind testing this branch ^ to see if it addresses all the warnings you're hitting on your project?

Awesome. On it.

DanCardin commented 2 years ago

Released in 2.2.7, just to not block it on your having to manually test on a branch. I can do another patch release if there's more problems not covered by our tests.

michaelbukachi commented 2 years ago

Released in 2.2.7, just to not block it on your having to manually test on a branch. I can do another patch release if there's more problems not covered by our tests.

Working great :fire: