Skip to content
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

Enable savepints for all engines. Add disable_savepoints param #45

Closed
wants to merge 2 commits into from

Conversation

lrowe
Copy link
Contributor

@lrowe lrowe commented Mar 31, 2020

Fixes #44. Looking for feedback but requires documentation before merging.

From my Travis tests it appears Python 3.6 was the first to ship with a SQLite version that supports savepoints. (It's possible to hack in support using pysqlite for earlier versions using: https://github.com/lrowe/pysqlite/wiki/Building-pysqlite-with-static-env-and-savepoints.)

Should this be considered a breaking change? Potentially those running older versions of SQLite may now need to add disable_savepoints=True to their register call.

@icemac
Copy link
Member

icemac commented Mar 31, 2020

I like this PR although I am not using this library against SQLite on Python < 3.6.
I'd consider this a breaking change as we should not yet drop support for Python < 3.6.

Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

What happens if you're on Python 3.5 and try to use savepoints?

According to the removed assertion in the unit test, previously you'd get a TypeError at the point where you called transaction.savepoint().

If the new code can do the same, I'd say we can merge it (but we should keep the unit test with that assertion, in case SQLITE_NO_SAVEPOINT is True).

@@ -147,11 +146,7 @@ def savepoint(self):
# support savepoints but Postgres is whitelisted independent of its
# version. Possibly additional version information should be taken
# into account (ajung)
Copy link
Member

Choose a reason for hiding this comment

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

This comment is outdated now you're no longer checking engine names.

@lrowe
Copy link
Contributor Author

lrowe commented Mar 31, 2020

@mgedmin transaction.savepoint() without optimistic=True raises a TypeError when one of its data managers is missing a savepoint method. To get that same behaviour you would need to use zope.sqlalchemy.register(disable_savepoints=True).

If not and your database/driver does not support subtransactions you get a sqlalchemy.exc.OperationalError when the database errors on the transaction.commit() or .rollback() having called transaction.savepoint() in the transaction. Example test failures before I added the version based unittest.skipIf: https://travis-ci.org/github/zopefoundation/zope.sqlalchemy/jobs/668966939

I'm reluctant to try and make a decision automagically as the logic required will likely be incomplete and error prone. "Explicit is better than implicit" and all that.

Python 2.7 and 3.5 sqlite who are using savepoints (likely optimistic ones) should either:

  • stay on zope.sqlalchemy 1.3
  • specify disable_savepoints=True
  • install pysqlite >= 2.8.0 to get working savepoints

According to https://devguide.python.org/#status-of-python-branches Python 3.5 end-of-life is September this year. Perhaps it's enough to just clearly document this and call it out in the changelog?

@icemac
Copy link
Member

icemac commented Apr 3, 2020

I think documenting is enough.

@dwt
Copy link

dwt commented Nov 24, 2020

What exactly is missing to get this pull request to continue? I just had to add an ugly workaround in my app because of this - and I would like to get rid of it soon. :-)

@sallner
Copy link
Member

sallner commented Apr 26, 2021

@dwt We need the following:

  • Rebase to master
  • Add documentation of the non-support in readme and changelog
  • Fix comment in code.

@lrowe Do you intend to work on that soon, or should someone else step in?

@icemac
Copy link
Member

icemac commented Feb 14, 2024

I am closing this old PR. Feel free to re-open it if you want to work on it.

@icemac icemac closed this Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite do support SAVEPOINT
5 participants