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

Method test_count_with_bindparams

test/ext/test_baked.py:270–290  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

268 )
269
270 def test_count_with_bindparams(self):
271 User = self.classes.User
272
273 bq = self.bakery(lambda s: s.query(User))
274
275 sess = fixture_session()
276
277 eq_(bq(sess).count(), 4)
278
279 bq += lambda q: q.filter(User.name == bindparam("uname"))
280 # calling with *args
281 eq_(bq(sess).params(uname="fred").count(), 1)
282 # with multiple params, the **kwargs will be used
283 bq += lambda q: q.filter(User.id == bindparam("an_id"))
284 eq_(bq(sess).params(uname="fred", an_id=9).count(), 1)
285
286 eq_(
287 # wrong id, so 0 results:
288 bq(sess).params(uname="fred", an_id=8).count(),
289 0,
290 )
291
292 def test_get_pk_w_null(self):
293 """test the re-implementation of logic to do get with IS NULL."""

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
eq_Function · 0.90
bindparamFunction · 0.90
bakeryMethod · 0.80
queryMethod · 0.45
countMethod · 0.45
filterMethod · 0.45
paramsMethod · 0.45

Tested by

no test coverage detected