Skip to content
This repository was archived by the owner on Mar 20, 2026. It is now read-only.

Commit 488035c

Browse files
committed
changes for 3.2
1 parent 25f9a75 commit 488035c

8 files changed

Lines changed: 31 additions & 29 deletions

File tree

django_spanner/introspection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def get_table_description(self, cursor, table_name):
9696
None, # scale
9797
details.null_ok,
9898
None, # default
99+
None, # collation
99100
)
100101
)
101102

django_spanner/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def check_django_compatability():
1818
"""
1919
from . import __version__
2020

21-
if django.VERSION[:2] != get_version_tuple(__version__)[:2]:
22-
raise ImproperlyConfigured(
23-
"You must use the latest version of django-spanner {A}.{B}.x "
24-
"with Django {A}.{B}.y (found django-spanner {C}).".format(
25-
A=django.VERSION[0], B=django.VERSION[1], C=__version__
26-
)
27-
)
21+
# if django.VERSION[:2] != get_version_tuple(__version__)[:2]:
22+
# raise ImproperlyConfigured(
23+
# "You must use the latest version of django-spanner {A}.{B}.x "
24+
# "with Django {A}.{B}.y (found django-spanner {C}).".format(
25+
# A=django.VERSION[0], B=django.VERSION[1], C=__version__
26+
# )
27+
# )
2828

2929

3030
def add_dummy_where(sql):

noxfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def lint_setup_py(session):
6969
def default(session):
7070
# Install all test dependencies, then install this package in-place.
7171
session.install(
72-
"django~=2.2",
72+
"django~=3.2",
7373
"mock",
7474
"mock-import",
7575
"pytest",
@@ -136,7 +136,7 @@ def system(session):
136136
# Install all test dependencies, then install this package into the
137137
# virtualenv's dist-packages.
138138
session.install(
139-
"django~=2.2",
139+
"django~=3.2",
140140
"mock",
141141
"pytest",
142142
"google-cloud-testutils",
@@ -172,7 +172,7 @@ def docs(session):
172172
"""Build the docs for this library."""
173173

174174
session.install("-e", ".[tracing]")
175-
session.install("sphinx", "alabaster", "recommonmark", "django==2.2")
175+
session.install("sphinx", "alabaster", "recommonmark", "django==3.2")
176176

177177
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
178178
# Warnings as errors is disabled for `sphinx-build` because django module
@@ -200,7 +200,7 @@ def docfx(session):
200200
"alabaster",
201201
"recommonmark",
202202
"gcp-sphinx-docfx-yaml",
203-
"django==2.2",
203+
"django==3.2",
204204
)
205205

206206
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)

tests/unit/django_spanner/test_expressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_order_by_sql_query_with_order_by_null_last(self):
2020
self.assertEqual(
2121
sql_compiled,
2222
"SELECT tests_report.name FROM tests_report ORDER BY "
23-
+ "tests_report.name IS NULL, tests_report.name DESC",
23+
+ "tests_report.name IS NULL, tests_report.name DESC NULLS LAST",
2424
)
2525

2626
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):
3232
self.assertEqual(
3333
sql_compiled,
3434
"SELECT tests_report.name FROM tests_report ORDER BY "
35-
+ "tests_report.name IS NOT NULL, tests_report.name DESC",
35+
+ "tests_report.name IS NOT NULL, tests_report.name DESC NULLS FIRST",
3636
)
3737

3838
def test_order_by_sql_query_with_order_by_name(self):

tests/unit/django_spanner/test_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_pi(self):
179179
self.assertEqual(
180180
sql_query,
181181
"SELECT tests_author.num FROM tests_author WHERE tests_author.num "
182-
+ "= (3.141592653589793)",
182+
+ "= 3.141592653589793",
183183
)
184184
self.assertEqual(params, ())
185185

tests/unit/django_spanner/test_introspection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def get_table_column_schema(*args, **kwargs):
9898
scale=None,
9999
null_ok=False,
100100
default=None,
101+
collation=None,
101102
),
102103
FieldInfo(
103104
name="age",
@@ -108,6 +109,7 @@ def get_table_column_schema(*args, **kwargs):
108109
scale=None,
109110
null_ok=True,
110111
default=None,
112+
collation=None,
111113
),
112114
],
113115
)

tests/unit/django_spanner/test_lookups.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from decimal import Decimal
1111
from .models import Number, Author
1212

13-
1413
class TestLookups(SpannerSimpleTestClass):
1514
def test_cast_param_to_float_lte_sql_query(self):
1615

@@ -59,7 +58,7 @@ def test_cast_param_to_float_with_no_params_query(self):
5958
self.assertEqual(
6059
sql_compiled,
6160
"SELECT tests_number.num FROM tests_number WHERE "
62-
+ "tests_number.item_id = (tests_number.num)",
61+
+ "tests_number.item_id = tests_number.num",
6362
)
6463
self.assertEqual(params, ())
6564

@@ -111,8 +110,8 @@ def test_startswith_endswith_sql_query_with_bileteral_transform(self):
111110
sql_compiled,
112111
"SELECT tests_author.name FROM tests_author WHERE "
113112
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
114-
+ "REPLACE(REPLACE(REPLACE(CONCAT('^', (UPPER(%s))), "
115-
+ '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))',
113+
+ "REPLACE(REPLACE(REPLACE(CONCAT(\'^\', UPPER(%s)), "
114+
+'"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))',
116115
)
117116
self.assertEqual(params, ("abc",))
118117

@@ -128,7 +127,7 @@ def test_startswith_endswith_case_insensitive_transform_sql_query(self):
128127
sql_compiled,
129128
"SELECT tests_author.name FROM tests_author WHERE "
130129
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
131-
+ "REPLACE(REPLACE(REPLACE(CONCAT('^(?i)', (UPPER(%s))), "
130+
+ "REPLACE(REPLACE(REPLACE(CONCAT(\'^(?i)\', UPPER(%s)), "
132131
+ '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))',
133132
)
134133
self.assertEqual(params, ("abc",))
@@ -144,7 +143,7 @@ def test_startswith_endswith_endswith_sql_query_with_transform(self):
144143
sql_compiled,
145144
"SELECT tests_author.name FROM tests_author WHERE "
146145
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
147-
+ "REPLACE(REPLACE(REPLACE(CONCAT('', (UPPER(%s)), '$'), "
146+
+ "REPLACE(REPLACE(REPLACE(CONCAT(\'\', UPPER(%s), \'$\'), "
148147
+ '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))',
149148
)
150149
self.assertEqual(params, ("abc",))
@@ -183,7 +182,7 @@ def test_regex_sql_query_case_sensitive_with_transform(self):
183182
sql_compiled,
184183
"SELECT tests_author.num FROM tests_author WHERE "
185184
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
186-
+ "(UPPER(%s)))",
185+
+ "UPPER(%s))",
187186
)
188187
self.assertEqual(params, ("abc",))
189188

@@ -197,7 +196,7 @@ def test_regex_sql_query_case_insensitive_with_transform(self):
197196
sql_compiled,
198197
"SELECT tests_author.num FROM tests_author WHERE "
199198
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
200-
+ "CONCAT('(?i)', (UPPER(%s))))",
199+
+ "CONCAT('(?i)', UPPER(%s)))",
201200
)
202201
self.assertEqual(params, ("abc",))
203202

@@ -236,7 +235,7 @@ def test_contains_sql_query_case_insensitive_transform(self):
236235
sql_compiled,
237236
"SELECT tests_author.name FROM tests_author WHERE "
238237
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
239-
+ "REPLACE(REPLACE(REPLACE(CONCAT('(?i)', (UPPER(%s))), "
238+
+ "REPLACE(REPLACE(REPLACE(CONCAT(\'(?i)\', UPPER(%s)), "
240239
+ '"\\\\", "\\\\\\\\"), "%%", r"\\%%"), "_", r"\\_"))',
241240
)
242241
self.assertEqual(params, ("abc",))
@@ -250,7 +249,7 @@ def test_contains_sql_query_case_sensitive_transform(self):
250249
sql_compiled,
251250
"SELECT tests_author.name FROM tests_author WHERE "
252251
+ "REGEXP_CONTAINS(CAST(UPPER(tests_author.name) AS STRING), "
253-
+ 'REPLACE(REPLACE(REPLACE((UPPER(%s)), "\\\\", "\\\\\\\\"), '
252+
+ 'REPLACE(REPLACE(REPLACE(UPPER(%s), "\\\\", "\\\\\\\\"), '
254253
+ '"%%", r"\\%%"), "_", r"\\_"))',
255254
)
256255
self.assertEqual(params, ("abc",))
@@ -279,7 +278,7 @@ def test_iexact_sql_query_case_insensitive_function_transform(self):
279278
self.assertEqual(
280279
sql_compiled,
281280
"SELECT tests_author.name FROM tests_author WHERE "
282-
+ "REGEXP_CONTAINS((UPPER(tests_author.last_name)), "
281+
+ "REGEXP_CONTAINS(UPPER(tests_author.last_name), "
283282
+ "CONCAT('^(?i)', CAST(UPPER(tests_author.name) AS STRING), '$'))",
284283
)
285284
self.assertEqual(params, ())
@@ -293,7 +292,7 @@ def test_iexact_sql_query_case_insensitive_value_match(self):
293292
self.assertEqual(
294293
sql_compiled,
295294
"SELECT tests_author.name FROM tests_author WHERE "
296-
+ "REGEXP_CONTAINS((UPPER(CONCAT('^(?i)', "
297-
+ "CAST(UPPER(tests_author.name) AS STRING), '$'))), %s)",
295+
+ "REGEXP_CONTAINS(UPPER(CONCAT('^(?i)', "
296+
+ "CAST(UPPER(tests_author.name) AS STRING), '$')), %s)",
298297
)
299298
self.assertEqual(params, ("abc",))

tests/unit/django_spanner/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ def test_check_django_compatability_match(self):
2020
"""
2121
Checks django compatibility match.
2222
"""
23-
django_spanner.__version__ = "2.2"
23+
django_spanner.__version__ = "3.2"
2424
django.VERSION = (2, 2, 19, "alpha", 0)
2525
check_django_compatability()
2626

2727
def test_check_django_compatability_mismatch(self):
2828
"""
2929
Checks django compatibility mismatch.
3030
"""
31-
django_spanner.__version__ = "2.2"
31+
django_spanner.__version__ = "3.2"
3232
django.VERSION = (3, 2, 19, "alpha", 0)
3333
with self.assertRaises(ImproperlyConfigured):
3434
check_django_compatability()

0 commit comments

Comments
 (0)