Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ def readme():
"google-auth>=1.25.0,<3.0.0dev", # Work around pip wack.
"google-cloud-bigquery>=2.25.2,<4.0.0dev",
"google-cloud-bigquery-storage>=2.0.0,<3.0.0dev",
"packaging",
"pyarrow>=3.0.0",
"sqlalchemy>=1.2.0",
"sqlalchemy>=1.2.0,<2.0.0dev",
"future",
],
extras_require=extras,
Expand Down
14 changes: 9 additions & 5 deletions sqlalchemy_bigquery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from google.cloud.bigquery import dbapi
from google.cloud.bigquery.table import TableReference
from google.api_core.exceptions import NotFound

import packaging.version
import sqlalchemy
import sqlalchemy.sql.expression
import sqlalchemy.sql.functions
Expand Down Expand Up @@ -340,14 +340,18 @@ def group_by_clause(self, select, **kw):
# no way to tell sqlalchemy that, so it works harder than
# necessary and makes us do the same.

__sqlalchemy_version_info = tuple(map(int, sqlalchemy.__version__.split(".")))
__sqlalchemy_version_info = packaging.version.parse(sqlalchemy.__version__)

__expanding_text = (
"EXPANDING" if __sqlalchemy_version_info < (1, 4) else "POSTCOMPILE"
"EXPANDING"
if __sqlalchemy_version_info < packaging.version.parse("1.4")
else "POSTCOMPILE"
)

# https://github.com/sqlalchemy/sqlalchemy/commit/f79df12bd6d99b8f6f09d4bf07722638c4b4c159
__expanding_conflict = "" if __sqlalchemy_version_info < (1, 4, 27) else "__"
__expanding_conflict = (
"" if __sqlalchemy_version_info < packaging.version.parse("1.4.27") else "__"
)

__in_expanding_bind = _helpers.substitute_string_re_method(
rf"""
Expand Down Expand Up @@ -529,7 +533,7 @@ def visit_bindparam(

if bindparam.expanding: # pragma: NO COVER
assert_(self.__expanded_param(param), f"Unexpected param: {param}")
if self.__sqlalchemy_version_info < (1, 4, 27):
if self.__sqlalchemy_version_info < packaging.version.parse("1.4.27"):
param = param.replace(")", f":{bq_type})")

else:
Expand Down