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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: in-operator literal binds not handled properly #285

Conversation

jimfulton
Copy link
Contributor

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #252 馃

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API. label Aug 19, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 19, 2021
@jimfulton jimfulton closed this Aug 19, 2021
@jimfulton jimfulton deleted the literal_binds_kwarg_with_an_IN_operator_252 branch August 19, 2021 22:26
@jimfulton jimfulton restored the literal_binds_kwarg_with_an_IN_operator_252 branch August 20, 2021 14:04
@jimfulton jimfulton reopened this Aug 20, 2021
@jimfulton jimfulton marked this pull request as ready for review August 20, 2021 16:17
@jimfulton jimfulton requested a review from a team as a code owner August 20, 2021 16:17
@jimfulton
Copy link
Contributor Author

Reviewers:

https://github.com/googleapis/python-bigquery-sqlalchemy/pull/285/files#diff-efe1987a73ae5b54aa817dc8c70541025df89d9d08601c8ab33fa84ad8c09de7R423

This PR boils down to this line:
https://github.com/googleapis/python-bigquery-sqlalchemy/pull/285/files#diff-efe1987a73ae5b54aa817dc8c70541025df89d9d08601c8ab33fa84ad8c09de7R423

Normally, IN SQLAlchemy, when you pass values from Python, the values are passes as parameters. We override a methid, visit_bindparam, that controls this. For BQ, which is picky about types, we do this so we can pass type information to BQ.

OTOH, for "literal" binds, values get knit into the SQL and aren't passes as parameters to the DB API. In this case, we can just call the base method and be done.

@jimfulton jimfulton merged commit e06bf74 into googleapis:master Aug 23, 2021
@jimfulton jimfulton deleted the literal_binds_kwarg_with_an_IN_operator_252 branch August 23, 2021 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-sqlalchemy API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query compilation breaks using the literal_binds kwarg with an IN operator in the Query on SQLAlchemy 1.4
2 participants