Is it possible to use like() on a composite object attribute to filter a particular query? I'm trying to pull records in from a postgres db based on a the value of a single attribute within a composite object. For example, with the setup below, I want to search for records that have a url_domain like '%google.com' regardless of the other values. Looking through the docs and Google, I'm guessing that I need to use the comparator factory, but I wasn't quite sure how to accomplish my goal.

Thanks in advance.

(Since I had to re-type all this instead of cut-and-paste, I left out a lot of the other column names, etc.)

class URL(object):
    def __init__(self, url):
        url = urlparse(url)

        self.scheme = url.scheme
        self.domain = url.domain
        self.path   = url.path
        self.query  = url.query

    def __composite_values__(self):
        return [self.scheme, self.domain, self.path, self.query]

class Product(Base):
    ...
    url = composite(URL, \
               Column('url_scheme', String), \
               Column('url_domain', String), \
               Column('url_path', String), \
               Column('url_query', String))

recs = session.query(Product).filter(Product.url.url_domain.like('%google.com')

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to