Query with joins / Common Relationship Operators / any() example failed with keywords arguments
Issue #3894
invalid
Hi,
Executing any() with keywords arguments failed :
session.query(User).filter(User.addresses.any(email_address == 'bar')).all()
NameError Traceback (most recent call last)
<ipython-input-283-64461588492b> in <module>()
----> 1 session.query(User).filter(User.addresses.any(email_address == 'bar')).all()
NameError: name 'email_address' is not defined
The first example with the name of the table is working:
session.query(User).filter(User.addresses.any(Address.email_address == 'bar')).all()
2017-01-24 15:08:20,153 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.name AS users_name, users.fullname AS users_fullname, users.password AS users_password
FROM users
WHERE EXISTS (SELECT 1
FROM addresses
WHERE users.id = addresses.user_id AND addresses.email_address = ?)
2017-01-24 15:08:20,153 INFO sqlalchemy.engine.base.Engine ('bar',)
[]
Regards
Comments (4)
-
repo owner -
repo owner - changed status to invalid
you can see working examples later down in the section "Building a Many to Many Relationship", in that these examples actually run under doctest as part of the test suite.
-
reporter Hi,
So sorry, it was my mistake, this is working as written in the documentation.
Thank you for this great library and the perfect documentation Regards
-
reporter - changed status to invalid
- Log in to comment
hi there -
that's not keyword argument form, you'd mean to say: any(email_address = 'bar').