diff --git a/django_spanner/introspection.py b/django_spanner/introspection.py index b95ea3e629..95db6723d5 100644 --- a/django_spanner/introspection.py +++ b/django_spanner/introspection.py @@ -96,6 +96,7 @@ def get_table_description(self, cursor, table_name): None, # scale details.null_ok, None, # default + None, # collation ) ) diff --git a/django_test_suite.sh b/django_test_suite.sh index 17173cc2f9..85bc2a1e9b 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -18,7 +18,7 @@ mkdir -p $DJANGO_TESTS_DIR if [ $SPANNER_EMULATOR_HOST != 0 ] then pip3 install . - git clone --depth 1 --single-branch --branch "spanner/stable/2.2.x" https://github.com/c24t/django.git $DJANGO_TESTS_DIR/django + git clone --depth 1 --single-branch --branch "spanner/stable/3.2.x" https://github.com/c24t/django.git $DJANGO_TESTS_DIR/django fi # Install dependencies for Django tests. diff --git a/noxfile.py b/noxfile.py index a5c05e7a02..bcfe118ca3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -69,7 +69,7 @@ def lint_setup_py(session): def default(session): # Install all test dependencies, then install this package in-place. session.install( - "django~=2.2", + "django~=3.2", "mock", "mock-import", "pytest", @@ -136,7 +136,7 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. session.install( - "django~=2.2", + "django~=3.2", "mock", "pytest", "google-cloud-testutils", @@ -172,7 +172,7 @@ def docs(session): """Build the docs for this library.""" session.install("-e", ".[tracing]") - session.install("sphinx", "alabaster", "recommonmark", "django==2.2") + session.install("sphinx", "alabaster", "recommonmark", "django==3.2") shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) # Warnings as errors is disabled for `sphinx-build` because django module @@ -200,7 +200,7 @@ def docfx(session): "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml", - "django==2.2", + "django==3.2", ) shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) diff --git a/tests/unit/django_spanner/test_expressions.py b/tests/unit/django_spanner/test_expressions.py index 0efc99ce08..ae5b53f4f8 100644 --- a/tests/unit/django_spanner/test_expressions.py +++ b/tests/unit/django_spanner/test_expressions.py @@ -20,7 +20,7 @@ def test_order_by_sql_query_with_order_by_null_last(self): self.assertEqual( sql_compiled, "SELECT tests_report.name FROM tests_report ORDER BY " - + "tests_report.name IS NULL, tests_report.name DESC", + + "tests_report.name IS NULL, tests_report.name DESC NULLS LAST", ) def test_order_by_sql_query_with_order_by_null_first(self): @@ -32,7 +32,7 @@ def test_order_by_sql_query_with_order_by_null_first(self): self.assertEqual( sql_compiled, "SELECT tests_report.name FROM tests_report ORDER BY " - + "tests_report.name IS NOT NULL, tests_report.name DESC", + + "tests_report.name IS NOT NULL, tests_report.name DESC NULLS FIRST", ) def test_order_by_sql_query_with_order_by_name(self): diff --git a/tests/unit/django_spanner/test_functions.py b/tests/unit/django_spanner/test_functions.py index 00b431b73b..b24a2290e9 100644 --- a/tests/unit/django_spanner/test_functions.py +++ b/tests/unit/django_spanner/test_functions.py @@ -179,7 +179,7 @@ def test_pi(self): self.assertEqual( sql_query, "SELECT tests_author.num FROM tests_author WHERE tests_author.num " - + "= (3.141592653589793)", + + "= 3.141592653589793", ) self.assertEqual(params, ()) diff --git a/tests/unit/django_spanner/test_introspection.py b/tests/unit/django_spanner/test_introspection.py index c90288f3b3..03b5b67ca9 100644 --- a/tests/unit/django_spanner/test_introspection.py +++ b/tests/unit/django_spanner/test_introspection.py @@ -98,6 +98,7 @@ def get_table_column_schema(*args, **kwargs): scale=None, null_ok=False, default=None, + collation=None, ), FieldInfo( name="age", @@ -108,6 +109,7 @@ def get_table_column_schema(*args, **kwargs): scale=None, null_ok=True, default=None, + collation=None, ), ], ) diff --git a/tests/unit/django_spanner/test_lookups.py b/tests/unit/django_spanner/test_lookups.py index 53604691cc..3eb4812a6f 100644 --- a/tests/unit/django_spanner/test_lookups.py +++ b/tests/unit/django_spanner/test_lookups.py @@ -59,7 +59,7 @@ def test_cast_param_to_float_with_no_params_query(self): self.assertEqual( sql_compiled, "SELECT tests_number.num FROM tests_number WHERE " - + "tests_number.item_id = (tests_number.num)", + + "tests_number.item_id = tests_number.num", ) self.assertEqual(params, ()) @@ -111,7 +111,7 @@ def test_startswith_endswith_sql_query_with_bileteral_transform(self): sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "REPLACE(REPLACE(REPLACE(CONCAT('^', (UPPER(%s))), " + + "REPLACE(REPLACE(REPLACE(CONCAT('^', UPPER(%s)), " + '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))', ) self.assertEqual(params, ("abc",)) @@ -128,7 +128,7 @@ def test_startswith_endswith_case_insensitive_transform_sql_query(self): sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "REPLACE(REPLACE(REPLACE(CONCAT('^(?i)', (UPPER(%s))), " + + "REPLACE(REPLACE(REPLACE(CONCAT('^(?i)', UPPER(%s)), " + '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))', ) self.assertEqual(params, ("abc",)) @@ -144,7 +144,7 @@ def test_startswith_endswith_endswith_sql_query_with_transform(self): sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "REPLACE(REPLACE(REPLACE(CONCAT('', (UPPER(%s)), '$'), " + + "REPLACE(REPLACE(REPLACE(CONCAT('', UPPER(%s), '$'), " + '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))', ) self.assertEqual(params, ("abc",)) @@ -183,7 +183,7 @@ def test_regex_sql_query_case_sensitive_with_transform(self): sql_compiled, "SELECT tests_author.num FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "(UPPER(%s)))", + + "UPPER(%s))", ) self.assertEqual(params, ("abc",)) @@ -197,7 +197,7 @@ def test_regex_sql_query_case_insensitive_with_transform(self): sql_compiled, "SELECT tests_author.num FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "CONCAT('(?i)', (UPPER(%s))))", + + "CONCAT('(?i)', UPPER(%s)))", ) self.assertEqual(params, ("abc",)) @@ -236,7 +236,7 @@ def test_contains_sql_query_case_insensitive_transform(self): sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + "REPLACE(REPLACE(REPLACE(CONCAT('(?i)', (UPPER(%s))), " + + "REPLACE(REPLACE(REPLACE(CONCAT('(?i)', UPPER(%s)), " + '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))', ) self.assertEqual(params, ("abc",)) @@ -250,7 +250,7 @@ def test_contains_sql_query_case_sensitive_transform(self): sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " + "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), " - + 'REPLACE(REPLACE(REPLACE((UPPER(%s)), "\\\\", "\\\\\\\\"), ' + + 'REPLACE(REPLACE(REPLACE(UPPER(%s), "\\\\", "\\\\\\\\"), ' + '"%%", r"\\%%"), "_", r"\\_"))', ) self.assertEqual(params, ("abc",)) @@ -279,7 +279,7 @@ def test_iexact_sql_query_case_insensitive_function_transform(self): self.assertEqual( sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " - + "REGEXP_CONTAINS((UPPER(tests_author.last_name)), " + + "REGEXP_CONTAINS(UPPER(tests_author.last_name), " + "CONCAT('^(?i)', CAST(UPPER(tests_author.name) AS STRING), '$'))", ) self.assertEqual(params, ()) @@ -293,7 +293,7 @@ def test_iexact_sql_query_case_insensitive_value_match(self): self.assertEqual( sql_compiled, "SELECT tests_author.name FROM tests_author WHERE " - + "REGEXP_CONTAINS((UPPER(CONCAT('^(?i)', " - + "CAST(UPPER(tests_author.name) AS STRING), '$'))), %s)", + + "REGEXP_CONTAINS(UPPER(CONCAT('^(?i)', " + + "CAST(UPPER(tests_author.name) AS STRING), '$')), %s)", ) self.assertEqual(params, ("abc",)) diff --git a/version.py b/version.py index df949c65d1..3c579da8db 100644 --- a/version.py +++ b/version.py @@ -4,4 +4,4 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd -__version__ = "2.2.1b2" +__version__ = "3.2.5"