-
Notifications
You must be signed in to change notification settings - Fork 133
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: POSTCOMPILE expansion in SQLAlchemy 1.4.27+ #408
Conversation
We don't have the resources to backport to |
All good, thought I'd ask. :) Not sure what the deal is with the compliance tests. Pushed a commit that gets it at least running for 3.8 on my local but not sure it'll pass... Any advice? |
I've got a fix coming in #401 The older versions of SQLAlchemy aren't compatible with pytest 7+. Just waiting on a teammate to review the PR. |
Ah, I see! |
@jethron It looks like you haven't enabled "allow commits from maintainers". Could you sync with main and also update |
Handle the new double underscore prefix for POSTCOMPILE variables introduced in this version.
Sorry @tswast, TIL isaacs/github#1681 will fork to my user account next time. Rebased and updated setup.py. I just went to 1.4.27 even though I think this should work for higher too, but not sure if that will add further incompitabilities or not. |
Think that fixes the failing test. Not positive on what that line does, so I've just wrapped it in the same if-guard for 1.4.27+. Can I get another force-run? |
@@ -523,7 +528,8 @@ def visit_bindparam( | |||
|
|||
if bindparam.expanding: | |||
assert_(self.__expanded_param(param), f"Unexpected param: {param}") | |||
param = param.replace(")", f":{bq_type})") | |||
if self.__sqlalchemy_version_info < (1, 4, 27): | |||
param = param.replace(")", f":{bq_type})") |
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'll need to take a closer look at this. I believe this is required to pass in the type information about sometimes ambiguous query parameters.
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.
Looking at the failing test, there ends up with an extra trailing parentheses and the type information doesn't appear to have been extracted.
[SQL: select id FROM some_table WHERE z IN (%(q_1)s, %(q_2)s, %(q_3)s:STRING) ORDER BY id]
It does seem this change is necessary, but I wish I understood what had changed in 1.4.27 that requires it.
@@ -523,7 +528,8 @@ def visit_bindparam( | |||
|
|||
if bindparam.expanding: | |||
assert_(self.__expanded_param(param), f"Unexpected param: {param}") | |||
param = param.replace(")", f":{bq_type})") | |||
if self.__sqlalchemy_version_info < (1, 4, 27): |
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.
Looks like we're missing unit test coverage of entering the if bindparam.expanding
if statement, but SQLAlchemy >= 1.4.27
sqlalchemy_bigquery/base.py 481 0 172 1 99% 531->541
I would have thought that the update to setup.py
would make sure the tests run, though. 🤔
Compliance tests and system tests are passing! 🎉 Thanks so much. Hopefully we can figure out the coverage issue. If not, I wouldn't be too opposed to a |
Handle the new double underscore prefix for POSTCOMPILE variables introduced in SQLAlchemy 1.4.27 onwards. (See commit sqlalchemy#f79df12bd6d99b8f6f09d4bf07722638c4b4c159)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Related to #385 🦕
Actually encountered this issue in
pybigquery
(dependency for great_expectations), not sure if there's a backporting process or if that's just completely unsupported now?