Hi. Couple of questions...

 

1. Does SQLA support "deep filtering", i.e. something like this:

 

query(Invoice).filter(Invoice.Customer.Country.name=='France')

 

This does not work as it is, but is there something along this lines (except
of going with query.filter(.query.filter(.query.filter(query.get()))))?

 

2.Can I use hybrid properties for filtering? I tried to do that, but that's
what I got:

 

class Person(Base):

    first_name = Column(String(50))

    last_name = Column(String(50))

 

    def __init__(self, first, last):

        self.first_name = first

        self.last_name = last

 

    @hybrid_property

    def full_name(self):

        print(self.first_name, self.last_name)

        return self.first_name + " " + self.last_name

 

p = Person('John', 'Doe')

s.commit()

res = s.query(Person).filter(Person.full_name=='John Doe').all()

 

output:

Person.first_name Person.last_name

[]

 

Apparently, Person.full_name receives a class as an argument instead of an
instance. Is there other way?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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