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

Method test_expanding_in

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

Source from the content-addressed store, hash-verified

599 assert len(r) == 0
600
601 def test_expanding_in(self, connection):
602 users = self.tables.users
603 connection.execute(
604 users.insert(),
605 [
606 dict(user_id=7, user_name="jack"),
607 dict(user_id=8, user_name="fred"),
608 dict(user_id=9, user_name=None),
609 ],
610 )
611
612 stmt = (
613 select(users)
614 .where(users.c.user_name.in_(bindparam("uname", expanding=True)))
615 .order_by(users.c.user_id)
616 )
617
618 eq_(
619 connection.execute(stmt, {"uname": ["jack"]}).fetchall(),
620 [(7, "jack")],
621 )
622
623 eq_(
624 connection.execute(stmt, {"uname": ["jack", "fred"]}).fetchall(),
625 [(7, "jack"), (8, "fred")],
626 )
627
628 eq_(connection.execute(stmt, {"uname": []}).fetchall(), [])
629
630 assert_raises_message(
631 exc.StatementError,
632 "'expanding' parameters can't be used with executemany()",
633 connection.execute,
634 users.update().where(
635 users.c.user_name.in_(bindparam("uname", expanding=True))
636 ),
637 [{"uname": ["fred"]}, {"uname": ["ed"]}],
638 )
639
640 @testing.requires.no_quoting_special_bind_names
641 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