@@ -42,8 +42,9 @@ def contains(self, compiler, connection):
4242 :rtype: tuple[str, str]
4343 :returns: A tuple of the SQL request and parameters.
4444 """
45- lhs_sql , params = self .process_lhs (compiler , connection )
45+ lhs_sql , lhs_params = self .process_lhs (compiler , connection )
4646 rhs_sql , rhs_params = self .process_rhs (compiler , connection )
47+ params = list (lhs_params )
4748 params .extend (rhs_params )
4849 is_icontains = self .lookup_name .startswith ("i" )
4950 if self .rhs_is_direct_value () and params and not self .bilateral_transforms :
@@ -55,7 +56,7 @@ def contains(self, compiler, connection):
5556 if is_icontains :
5657 params [0 ] = "(?i)" + params [0 ]
5758 # rhs_sql is REGEXP_CONTAINS(%s, %%s), and lhs_sql is the column name.
58- return rhs_sql % lhs_sql , params
59+ return rhs_sql % lhs_sql , tuple ( params )
5960 else :
6061 # rhs_sql is the expression/column to use as the base of the regular
6162 # expression.
@@ -64,7 +65,7 @@ def contains(self, compiler, connection):
6465 return (
6566 "REGEXP_CONTAINS(%s, %s)"
6667 % (lhs_sql , connection .pattern_esc .format (rhs_sql )),
67- params ,
68+ tuple ( params ) ,
6869 )
6970
7071
@@ -89,8 +90,9 @@ def iexact(self, compiler, connection):
8990 :rtype: tuple[str, str]
9091 :returns: A tuple of the SQL request and parameters.
9192 """
92- lhs_sql , params = self .process_lhs (compiler , connection )
93+ lhs_sql , lhs_params = self .process_lhs (compiler , connection )
9394 rhs_sql , rhs_params = self .process_rhs (compiler , connection )
95+ params = list (lhs_params )
9496 params .extend (rhs_params )
9597 rhs_sql = self .get_rhs_op (connection , rhs_sql )
9698 # Wrap the parameter in ^ and $ to restrict the regex to an exact match.
@@ -113,7 +115,7 @@ def iexact(self, compiler, connection):
113115 rhs_sql = rhs_sql .replace ("%s" , "%%s" )
114116 rhs_sql = rhs_sql .replace ("__PLACEHOLDER_FOR_LHS_SQL__" , "%s" )
115117 # rhs_sql is REGEXP_CONTAINS(%s, %%s), and lhs_sql is the column name.
116- return rhs_sql % lhs_sql , params
118+ return rhs_sql % lhs_sql , tuple ( params )
117119
118120
119121def regex (self , compiler , connection ):
@@ -136,8 +138,9 @@ def regex(self, compiler, connection):
136138 :rtype: tuple[str, str]
137139 :returns: A tuple of the SQL request and parameters.
138140 """
139- lhs_sql , params = self .process_lhs (compiler , connection )
141+ lhs_sql , lhs_params = self .process_lhs (compiler , connection )
140142 rhs_sql , rhs_params = self .process_rhs (compiler , connection )
143+ params = list (lhs_params )
141144 params .extend (rhs_params )
142145 is_iregex = self .lookup_name .startswith ("i" )
143146 if self .rhs_is_direct_value () and params and not self .bilateral_transforms :
@@ -147,13 +150,13 @@ def regex(self, compiler, connection):
147150 else :
148151 params [0 ] = str (params [0 ])
149152 # rhs_sql is REGEXP_CONTAINS(%s, %%s), and lhs_sql is the column name.
150- return rhs_sql % lhs_sql , params
153+ return rhs_sql % lhs_sql , tuple ( params )
151154 else :
152155 # rhs_sql is the expression/column to use as the base of the regular
153156 # expression.
154157 if is_iregex :
155158 rhs_sql = "CONCAT('(?i)', " + rhs_sql + ")"
156- return "REGEXP_CONTAINS(%s, %s)" % (lhs_sql , rhs_sql ), params
159+ return "REGEXP_CONTAINS(%s, %s)" % (lhs_sql , rhs_sql ), tuple ( params )
157160
158161
159162def startswith_endswith (self , compiler , connection ):
@@ -179,8 +182,9 @@ def startswith_endswith(self, compiler, connection):
179182 :rtype: tuple[str, str]
180183 :returns: A tuple of the SQL request and parameters.
181184 """
182- lhs_sql , params = self .process_lhs (compiler , connection )
185+ lhs_sql , lhs_params = self .process_lhs (compiler , connection )
183186 rhs_sql , rhs_params = self .process_rhs (compiler , connection )
187+ params = list (lhs_params )
184188 params .extend (rhs_params )
185189 is_startswith = "startswith" in self .lookup_name
186190 is_endswith = "endswith" in self .lookup_name
@@ -197,7 +201,7 @@ def startswith_endswith(self, compiler, connection):
197201 if is_insensitive :
198202 params [0 ] = "(?i)" + params [0 ]
199203 # rhs_sql is REGEXP_CONTAINS(%s, %%s), and lhs_sql is the column name.
200- return rhs_sql % lhs_sql , params
204+ return rhs_sql % lhs_sql , tuple ( params )
201205 else :
202206 # rhs_sql is the expression/column to use as the base of the regular
203207 # expression.
@@ -212,7 +216,7 @@ def startswith_endswith(self, compiler, connection):
212216 sql += ")"
213217 return (
214218 "REGEXP_CONTAINS(%s, %s)" % (lhs_sql , connection .pattern_esc .format (sql )),
215- params ,
219+ tuple ( params ) ,
216220 )
217221
218222
@@ -241,6 +245,7 @@ def cast_param_to_float(self, compiler, connection):
241245 :returns: A tuple of the SQL request and float parameters.
242246 """
243247 sql , params = self .as_sql (compiler , connection )
248+ params = list (params ) if params else []
244249 if params :
245250 # Cast remote field lookups that must be integer but come in as string.
246251 if hasattr (self .lhs .output_field , "get_path_info" ):
@@ -251,7 +256,7 @@ def cast_param_to_float(self, compiler, connection):
251256 params [i ], str
252257 ):
253258 params [i ] = int (params [i ])
254- return sql , params
259+ return sql , tuple ( params )
255260
256261
257262def register_lookups ():
0 commit comments