MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_repeated_bindparams

Method test_repeated_bindparams

test/sql/test_query.py:273–289  ·  view source on GitHub ↗

Tests that a BindParam can be used more than once. This should be run for DB-APIs with both positional and named paramstyles.

(self, connection)

Source from the content-addressed store, hash-verified

271 )
272
273 def test_repeated_bindparams(self, connection):
274 """Tests that a BindParam can be used more than once.
275
276 This should be run for DB-APIs with both positional and named
277 paramstyles.
278 """
279 users = self.tables.users
280
281 connection.execute(users.insert(), dict(user_id=7, user_name="jack"))
282 connection.execute(users.insert(), dict(user_id=8, user_name="fred"))
283
284 u = bindparam("userid")
285 s = users.select().where(
286 and_(users.c.user_name == u, users.c.user_name == u)
287 )
288 r = connection.execute(s, dict(userid="fred")).fetchall()
289 assert len(r) == 1
290
291 def test_bindparam_detection(self):
292 dialect = default.DefaultDialect(paramstyle="qmark")

Callers

nothing calls this directly

Calls 7

bindparamFunction · 0.90
and_Function · 0.90
executeMethod · 0.45
insertMethod · 0.45
whereMethod · 0.45
selectMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected