MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_repeated_bindparams

Method test_repeated_bindparams

test/sql/test_query.py:297–313  ·  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

295 eq_(connection.execute(s, dict(id=7)).first()._mapping["user_id"], 7)
296
297 def test_repeated_bindparams(self, connection):
298 """Tests that a BindParam can be used more than once.
299
300 This should be run for DB-APIs with both positional and named
301 paramstyles.
302 """
303 users = self.tables.users
304
305 connection.execute(users.insert(), dict(user_id=7, user_name="jack"))
306 connection.execute(users.insert(), dict(user_id=8, user_name="fred"))
307
308 u = bindparam("userid")
309 s = users.select().where(
310 and_(users.c.user_name == u, users.c.user_name == u)
311 )
312 r = connection.execute(s, dict(userid="fred")).fetchall()
313 assert len(r) == 1
314
315 def test_bindparam_detection(self):
316 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