-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-45512: Simplify manage isolation level #29562
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
Conversation
@erlend-aasland Can you please take a look? |
|
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 like this change! However, I think we can improve it further :) See my comments; let me know what you think.
Modules/_sqlite/connection.c
Outdated
@@ -199,14 +188,14 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, | |||
} | |||
|
|||
if (isolation_level) { | |||
const char *stmt = get_begin_statement(isolation_level); | |||
if (stmt == NULL) { | |||
const char *level = get_isolation_level(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.
Now that there is no "isolation level to begin statement" conversion happening here, I find the get_isolation_level
name a bit strange. I would prefer to rename get_isolation_level
to validate_isolation_level
and make it return 0 on success and -1 on error.
Another thing: it would be super nice to add a custom AC converter that could handle this conversion. That would mean that __init__
was given a completely valid const char *isolation_level
, and we could just place it in self->isolation_level
without any fuzz! It would make __init__
even simpler.
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.
it would be super nice to add a custom AC converter that could handle this conversion.
I will left this part for you :)
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'm on it ;) I can submit a PR for it after this has landed. I don't think I can modify your PR.
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 would prefer to rename get_isolation_level to validate_isolation_level and make it return 0 on success and -1 on error.
I withdraw this suggestion. We need to revert this particular change; we need to be sure that the pointer is valid as long as the connection object is alive.
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'm on it ;) I can submit a PR for it after this has landed. I don't think I can modify your PR.
FTR: I opened GH-29593
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.
LGTM (with small nitpick comment; you can ignore it if you want). I'll add the AC converter in a new PR :)
(See my DM on Discord before merging) |
e6b11a6
to
8ef3bbb
Compare
|
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.
LGTM. Let's pull in the tests before landing.
FYI, you need to merge in |
af40fd6
to
d27cde7
Compare
@erlend-aasland |
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.
Great, LGTM!
https://bugs.python.org/issue45512