@@ -97,7 +97,7 @@ def test_select_with_ilike_no_escape(self):
9797 dedent ("""
9898 SELECT mytable.name, mytable.data
9999 FROM mytable
100- WHERE mytable.name ILIKE ?
100+ WHERE mytable.name ILIKE %(name_1)s
101101 """ ).strip (),
102102 ) # noqa: W291
103103 else :
@@ -106,7 +106,7 @@ def test_select_with_ilike_no_escape(self):
106106 dedent ("""
107107 SELECT mytable.name, mytable.data
108108 FROM mytable
109- WHERE lower(mytable.name) LIKE lower(? )
109+ WHERE lower(mytable.name) LIKE lower(%(name_1)s )
110110 """ ).strip (),
111111 ) # noqa: W291
112112
@@ -122,7 +122,7 @@ def test_select_with_not_ilike_no_escape(self):
122122 dedent ("""
123123 SELECT mytable.name, mytable.data
124124 FROM mytable
125- WHERE lower(mytable.name) NOT LIKE lower(? )
125+ WHERE lower(mytable.name) NOT LIKE lower(%(name_1)s )
126126 """ ).strip (),
127127 ) # noqa: W291
128128 else :
@@ -131,7 +131,7 @@ def test_select_with_not_ilike_no_escape(self):
131131 dedent ("""
132132 SELECT mytable.name, mytable.data
133133 FROM mytable
134- WHERE mytable.name NOT ILIKE ?
134+ WHERE mytable.name NOT ILIKE %(name_1)s
135135 """ ).strip (),
136136 ) # noqa: W291
137137
@@ -167,11 +167,13 @@ def test_select_with_offset(self):
167167 statement = str (selectable .compile (bind = self .crate_engine ))
168168 if SA_VERSION >= SA_1_4 :
169169 self .assertEqual (
170- statement , "SELECT mytable.name, mytable.data \n FROM mytable\n LIMIT ALL OFFSET ?"
170+ statement ,
171+ "SELECT mytable.name, mytable.data \n FROM mytable\n LIMIT ALL OFFSET %(param_1)s" ,
171172 )
172173 else :
173174 self .assertEqual (
174- statement , "SELECT mytable.name, mytable.data \n FROM mytable \n LIMIT ALL OFFSET ?"
175+ statement ,
176+ "SELECT mytable.name, mytable.data \n FROM mytable \n LIMIT ALL OFFSET %(param_1)s" ,
175177 )
176178
177179 def test_select_with_limit (self ):
@@ -180,7 +182,9 @@ def test_select_with_limit(self):
180182 """
181183 selectable = self .mytable .select ().limit (42 )
182184 statement = str (selectable .compile (bind = self .crate_engine ))
183- self .assertEqual (statement , "SELECT mytable.name, mytable.data \n FROM mytable \n LIMIT ?" )
185+ self .assertEqual (
186+ statement , "SELECT mytable.name, mytable.data \n FROM mytable \n LIMIT %(param_1)s"
187+ )
184188
185189 def test_select_with_offset_and_limit (self ):
186190 """
@@ -189,7 +193,9 @@ def test_select_with_offset_and_limit(self):
189193 selectable = self .mytable .select ().offset (5 ).limit (42 )
190194 statement = str (selectable .compile (bind = self .crate_engine ))
191195 self .assertEqual (
192- statement , "SELECT mytable.name, mytable.data \n FROM mytable \n LIMIT ? OFFSET ?"
196+ statement ,
197+ "SELECT mytable.name, mytable.data \n "
198+ "FROM mytable \n LIMIT %(param_1)s OFFSET %(param_2)s" ,
193199 )
194200
195201 def test_insert_multivalues (self ):
@@ -220,7 +226,10 @@ def test_insert_multivalues(self):
220226 records = [{"name" : f"foo_{ i } " } for i in range (3 )]
221227 insertable = self .mytable .insert ().values (records )
222228 statement = str (insertable .compile (bind = self .crate_engine ))
223- self .assertEqual (statement , "INSERT INTO mytable (name) VALUES (?), (?), (?)" )
229+ self .assertEqual (
230+ statement ,
231+ "INSERT INTO mytable (name) VALUES (%(name_m0)s), (%(name_m1)s), (%(name_m2)s)" ,
232+ )
224233
225234 @skipIf (
226235 SA_VERSION < SA_2_0 ,
@@ -263,7 +272,7 @@ def test_insert_manyvalues(self):
263272 records = [{"name" : f"foo_{ i } " } for i in range (record_count )]
264273 insertable = self .mytable .insert ()
265274 statement = str (insertable .compile (bind = self .crate_engine ))
266- self .assertEqual (statement , "INSERT INTO mytable (name, data) VALUES (?, ? )" )
275+ self .assertEqual (statement , "INSERT INTO mytable (name, data) VALUES (%(name)s, %(data)s )" )
267276
268277 with mock .patch (
269278 "crate.client.http.Client.sql" , autospec = True , return_value = {"cols" : []}
@@ -278,12 +287,18 @@ def test_insert_manyvalues(self):
278287 client_mock .mock_calls ,
279288 [
280289 mock .call (
281- mock .ANY , "INSERT INTO mytable (name) VALUES (?), (?)" , ("foo_0" , "foo_1" ), None
290+ mock .ANY ,
291+ "INSERT INTO mytable (name) VALUES ($1), ($2)" ,
292+ ["foo_0" , "foo_1" ],
293+ None ,
282294 ),
283295 mock .call (
284- mock .ANY , "INSERT INTO mytable (name) VALUES (?), (?)" , ("foo_2" , "foo_3" ), None
296+ mock .ANY ,
297+ "INSERT INTO mytable (name) VALUES ($1), ($2)" ,
298+ ["foo_2" , "foo_3" ],
299+ None ,
285300 ),
286- mock .call (mock .ANY , "INSERT INTO mytable (name) VALUES (? )" , ( "foo_4" ,) , None ),
301+ mock .call (mock .ANY , "INSERT INTO mytable (name) VALUES ($1 )" , [ "foo_4" ] , None ),
287302 ],
288303 )
289304
0 commit comments