Hi at all,
I haven't found something by googling, but I'm also not sure about the 
right search terms, so I hope some can help me here.

I have a model like this:

class Parent(DeclarativeBase):
    id = Column(Integer, primary_key=True)
    time = Column(Float)
    another_id = Column(Integer)

class Child(DeclarativeBase):
    id = Column(Integer, primary_key=True)
    parent_id = Column(Integer, ForeignKey('parent.id'), nullable=False)
    parent = relationship('Parent')
    _time = Column(Float, nullable=True)

    @property
    def time(self):
        return self._time or self.parent.time

So basically, a Child object may set it's own value for time, but if it's 
not set, it uses the value from its parent.
This works, but I would also like to be able to do something like:

session.query(Child).filter(Child.parent.another_id==2)

(Which would throw Neither 'InstrumentedAttribute' object nor 'Comparator' 
object has an attribute 'another_id')

And I wondered if this would be somewhat possible by using some of 
sqlalchemy's fancy extensions! ;)

Thanks in advance,
Moritz

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/YpW2PxLwfmYJ.
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