From 25b4acdc0df373a4621d6e8eda9933ada6cba75f Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Tue, 25 Oct 2022 14:27:37 +0000 Subject: [PATCH 1/4] Sets cache support to false, removes upper req limit --- setup.py | 2 +- sqlalchemy_bigquery/base.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4afe003e..3d876748 100644 --- a/setup.py +++ b/setup.py @@ -91,7 +91,7 @@ def readme(): # https://github.com/googleapis/python-bigquery-sqlalchemy/issues/386 # and # https://github.com/googleapis/python-bigquery-sqlalchemy/issues/385 - "sqlalchemy>=1.2.0,<=1.4.27", + "sqlalchemy>=1.2.0", "future", ], extras_require=extras, diff --git a/sqlalchemy_bigquery/base.py b/sqlalchemy_bigquery/base.py index 3a26b330..32247a45 100644 --- a/sqlalchemy_bigquery/base.py +++ b/sqlalchemy_bigquery/base.py @@ -733,6 +733,7 @@ class BigQueryDialect(DefaultDialect): supports_default_values = False supports_empty_insert = False supports_multivalues_insert = True + supports_statement_cache = False supports_unicode_statements = True supports_unicode_binds = True supports_native_decimal = True From df91fab635d6be623af39cc7f840324a44c56cb5 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Fri, 28 Oct 2022 18:52:52 +0000 Subject: [PATCH 2/4] fix: adds timestamp to ensure tests pass successfully --- .../test_dialect_compliance.py | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py b/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py index 5d575fc7..ce354713 100644 --- a/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +++ b/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py @@ -69,6 +69,24 @@ def literal(value): with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): super(TimestampMicrosecondsTest, self).test_literal() + def test_select_direct(self, connection): + # Added because this test was failing when passed the + # UTC timezone. + data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396) + + def literal(value, type_=None): + assert value == self.data + + if type_ is not None: + assert type_ is self.datatype + + import sqlalchemy.sql.sqltypes + + return sqlalchemy.sql.elements.literal(value, self.datatype) + + with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): + super(TimestampMicrosecondsTest, self).test_select_direct(connection) + else: from sqlalchemy.testing.suite import ( FetchLimitOffsetTest as _FetchLimitOffsetTest, @@ -109,7 +127,7 @@ def test_limit_render_multiple_times(self, connection): del PostCompileParamsTest class TimestampMicrosecondsTest(_TimestampMicrosecondsTest): - + print("HERE: ELSE") data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396, tzinfo=pytz.UTC) def test_literal(self, literal_round_trip): @@ -128,6 +146,27 @@ def literal(value, type_=None): with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): super(TimestampMicrosecondsTest, self).test_literal(literal_round_trip) + def test_select_direct(self, connection): + # Added because this test was failing when passed the + # UTC timezone. + print("HERE: my test select direct") + data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396) + + def literal(value, type_=None): + assert value == self.data + + if type_ is not None: + assert type_ is self.datatype + + import sqlalchemy.sql.sqltypes + + return sqlalchemy.sql.elements.literal(value, self.datatype) + + with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): + super(TimestampMicrosecondsTest, self).test_select_direct(connection) + + + def test_round_trip_executemany(self, connection): unicode_table = self.tables.unicode_table connection.execute( From d2a137a82d9edf07e9c144f5ab8126be73f82baa Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 2 Nov 2022 20:54:15 +0000 Subject: [PATCH 3/4] fix: updates tests to account for UTC --- noxfile.py | 2 +- .../test_dialect_compliance.py | 17 +++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/noxfile.py b/noxfile.py index 237da9e4..33d8e740 100644 --- a/noxfile.py +++ b/noxfile.py @@ -400,7 +400,7 @@ def compliance(session): "--only-rerun=409 Already Exists", "--only-rerun=404 Not found", "--only-rerun=400 Cannot execute DML over a non-existent table", - system_test_folder_path, + # system_test_folder_path, *session.posargs, ) diff --git a/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py b/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py index ce354713..4efb155e 100644 --- a/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +++ b/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py @@ -26,6 +26,7 @@ from sqlalchemy import and_ import sqlalchemy.testing.suite.test_types +import sqlalchemy.sql.sqltypes from sqlalchemy.testing import util from sqlalchemy.testing.assertions import eq_ from sqlalchemy.testing.suite import config, select, exists @@ -62,17 +63,14 @@ def test_literal(self): def literal(value): assert value == self.data - import sqlalchemy.sql.sqltypes - return sqlalchemy.sql.elements.literal(value, self.datatype) with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): super(TimestampMicrosecondsTest, self).test_literal() def test_select_direct(self, connection): - # Added because this test was failing when passed the + # This func added because this test was failing when passed the # UTC timezone. - data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396) def literal(value, type_=None): assert value == self.data @@ -80,8 +78,6 @@ def literal(value, type_=None): if type_ is not None: assert type_ is self.datatype - import sqlalchemy.sql.sqltypes - return sqlalchemy.sql.elements.literal(value, self.datatype) with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): @@ -127,7 +123,6 @@ def test_limit_render_multiple_times(self, connection): del PostCompileParamsTest class TimestampMicrosecondsTest(_TimestampMicrosecondsTest): - print("HERE: ELSE") data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396, tzinfo=pytz.UTC) def test_literal(self, literal_round_trip): @@ -139,18 +134,14 @@ def literal(value, type_=None): if type_ is not None: assert type_ is self.datatype - import sqlalchemy.sql.sqltypes - return sqlalchemy.sql.elements.literal(value, self.datatype) with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): super(TimestampMicrosecondsTest, self).test_literal(literal_round_trip) def test_select_direct(self, connection): - # Added because this test was failing when passed the + # This func added because this test was failing when passed the # UTC timezone. - print("HERE: my test select direct") - data = datetime.datetime(2012, 10, 15, 12, 57, 18, 396) def literal(value, type_=None): assert value == self.data @@ -165,8 +156,6 @@ def literal(value, type_=None): with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal): super(TimestampMicrosecondsTest, self).test_select_direct(connection) - - def test_round_trip_executemany(self, connection): unicode_table = self.tables.unicode_table connection.execute( From b2667a7e34ceb1a2a07d2b412cc8b7275b06dc82 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Thu, 3 Nov 2022 14:53:19 +0000 Subject: [PATCH 4/4] restores path in nox session --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 33d8e740..237da9e4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -400,7 +400,7 @@ def compliance(session): "--only-rerun=409 Already Exists", "--only-rerun=404 Not found", "--only-rerun=400 Cannot execute DML over a non-existent table", - # system_test_folder_path, + system_test_folder_path, *session.posargs, )