MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_select_from_alias_from_entity

Method test_select_from_alias_from_entity

test/orm/test_query.py:5984–6005  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5982 )
5983
5984 def test_select_from_alias_from_entity(self):
5985 User, Address = self.classes.User, self.classes.Address
5986
5987 sess = fixture_session()
5988 u1 = sess.get(User, 7)
5989 a1 = aliased(Address)
5990 a2 = aliased(Address)
5991 q = sess.query(a1, a2).filter(
5992 with_parent(u1, User.addresses, from_entity=a2)
5993 )
5994 self.assert_compile(
5995 q,
5996 "SELECT addresses_1.id AS addresses_1_id, "
5997 "addresses_1.user_id AS addresses_1_user_id, "
5998 "addresses_1.email_address AS addresses_1_email_address, "
5999 "addresses_2.id AS addresses_2_id, "
6000 "addresses_2.user_id AS addresses_2_user_id, "
6001 "addresses_2.email_address AS addresses_2_email_address "
6002 "FROM addresses AS addresses_1, "
6003 "addresses AS addresses_2 WHERE :param_1 = addresses_2.user_id",
6004 {"param_1": 7},
6005 )
6006
6007 def test_select_from_alias_of_type(self):
6008 User, Address = self.classes.User, self.classes.Address

Callers

nothing calls this directly

Calls 7

fixture_sessionFunction · 0.90
aliasedFunction · 0.90
with_parentFunction · 0.90
assert_compileMethod · 0.80
getMethod · 0.45
filterMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected