1010from decimal import Decimal
1111from .models import Number , Author
1212
13-
1413class 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" ,))
0 commit comments