First off, this is unusual because most people would just use the
primary attribute, association proxy isn't buying you anything here:
s.query(User).filter(User._all_emails.any(UserEmail.email.like('foo')))
vs.
s.query(User).filter(User.all_emails.any(UserEmail.email.like('foo')))
same
Ugh, somehow my reply sent by email nerver arrived here... here's my code:
https://gist.github.com/ThiefMaster/40cd1f91e2a792150496
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it,
In my user have I have an association proxy so I can access all email
addresses of the user via User.all_emails.
For a simple exact search I simply
.filter(User.all_emails.contains('f...@example.com')).
Is it also possible to use e.g. a LIKE match (besides manually joining the
Emails table and
FWIW, another option is to pull in all the addresses and use a class method
to filter.
class User():
def all_emails_like(self, expression):
return [e for e in self.all_emails if
regex_match(expression, e)]
I've found that depending on your app/db and the size of
That's the first thing I've tried. Unfortunately it doesn't work...
--- 1 User.find_all(User.all_emails.any(UserEmail.email.like('%adrian%')))
/home/adrian/dev/indico/env/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.pyc
in any(self, criterion, **kwargs)
367
368
On 4/27/15 1:52 PM, Adrian wrote:
That's the first thing I've tried. Unfortunately it doesn't work...
--- 1
User.find_all(User.all_emails.any(UserEmail.email.like('%adrian%')))
wait, what is UserEmail, that's the association. This would be the
endpoint class.
Can you share all three