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
--> 369 if self._value_is_scalar:
370 value_expr = getattr(
371 self.target_class, self.value_attr).has(criterion,
**kwargs)
/home/adrian/dev/indico/env/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.pyc
in __get__(self, obj, cls)
723 if obj is None:
724 return self
--> 725 obj.__dict__[self.__name__] = result = self.fget(obj)
726 return result
727
/home/adrian/dev/indico/env/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.pyc
in _value_is_scalar(self)
231 def _value_is_scalar(self):
232 return not self._get_property().\
--> 233 mapper.get_property(self.value_attr).uselist
234
235 @util.memoized_property
AttributeError: 'ColumnProperty' object has no attribute 'uselist'
My relationship and association proxy are defined like this:
_all_emails = db.relationship(
'UserEmail',
lazy=True,
viewonly=True,
primaryjoin='User.id == UserEmail.user_id',
collection_class=set,
backref=db.backref('user', lazy=False)
)
On Monday, April 27, 2015 at 5:28:49 PM UTC+2, Michael Bayer wrote:
>
>
> the has() / any() operators can allow this:
>
>
> User.all_emails.any(Email.email.like('%foo%'))
>
>
> it will produce an EXISTS subquery expression, which is not as efficient
> in SQL as a regular JOIN.
>
>
>
>
> --
> 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, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
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, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.