MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_expanding_in

Method test_expanding_in

test/sql/test_query.py:577–614  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

575 assert len(r) == 0
576
577 def test_expanding_in(self, connection):
578 users = self.tables.users
579 connection.execute(
580 users.insert(),
581 [
582 dict(user_id=7, user_name="jack"),
583 dict(user_id=8, user_name="fred"),
584 dict(user_id=9, user_name=None),
585 ],
586 )
587
588 stmt = (
589 select(users)
590 .where(users.c.user_name.in_(bindparam("uname", expanding=True)))
591 .order_by(users.c.user_id)
592 )
593
594 eq_(
595 connection.execute(stmt, {"uname": ["jack"]}).fetchall(),
596 [(7, "jack")],
597 )
598
599 eq_(
600 connection.execute(stmt, {"uname": ["jack", "fred"]}).fetchall(),
601 [(7, "jack"), (8, "fred")],
602 )
603
604 eq_(connection.execute(stmt, {"uname": []}).fetchall(), [])
605
606 assert_raises_message(
607 exc.StatementError,
608 "'expanding' parameters can't be used with executemany()",
609 connection.execute,
610 users.update().where(
611 users.c.user_name.in_(bindparam("uname", expanding=True))
612 ),
613 [{"uname": ["fred"]}, {"uname": ["ed"]}],
614 )
615
616 @testing.requires.no_quoting_special_bind_names
617 def test_expanding_in_special_chars(self, connection):

Callers

nothing calls this directly

Calls 11

selectFunction · 0.90
bindparamFunction · 0.90
eq_Function · 0.90
assert_raises_messageFunction · 0.90
executeMethod · 0.45
insertMethod · 0.45
order_byMethod · 0.45
whereMethod · 0.45
in_Method · 0.45
fetchallMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected