-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fix IsolationLevel.read_comitted and introduce IsolationLevel.default #770
Conversation
Codecov Report
@@ Coverage Diff @@
## master #770 +/- ##
==========================================
+ Coverage 93.08% 93.11% +0.03%
==========================================
Files 13 13
Lines 1532 1539 +7
Branches 172 172
==========================================
+ Hits 1426 1433 +7
Misses 78 78
Partials 28 28
Continue to review full report at Codecov.
|
aiopg/transaction.py
Outdated
|
||
def __init__(self, readonly, deferrable): | ||
if readonly or deferrable: | ||
raise ValueError("Readonly or deferrable are not supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why readonly and deferrable are not supported? As this object is running BEGIN
it should be able to support it, they are independent from the isolation level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was right that __slots__
was on the base class and that these properties are available to all the hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why readonly and deferrable are not supported? As this object is running BEGIN it should be able to support it, they are independent from the isolation level.
I dunno why it was unsupported, let me check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.postgresql.org/docs/13/sql-set-transaction.html
It looks like readonly supported for any isolation level, but deferred - only for serialisable with readonly.
But I'm a but unsure about current behaviour with raise of an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't impose a rule on top of what postgres implements.
If it's a no-op it may be a no-op only for the current implementation and change in the future. If the database accepts it, it is not the driver's business to decide to raise an exception.
This seems to work: the database doesn't raise exceptions or even warnings:
piro=# begin isolation level read uncommitted deferrable;
BEGIN
*piro=#
so I don't see a reason to special-case it and raise an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, thanks 🎉
PR introduces
IsolationLevel.default
and fixesIsolationLevel.read_comitted
as it was mentioned by @dvarrazzo.Are there changes in behavior for the user?
Instead of hacking
PR allows to pass
IsolationLevel
Related issue number
Fixes #699
Checklist