two choices.  join explicitly:

query(Event).join(Event.message).filter(Message.text.match(x))

or use has() which produces an EXISTS subquery:

query(Event).filter(Event.message.has(Message.text.match(x))


On Jan 7, 2009, at 1:23 PM, sol wrote:

>
> Using SA 0.5, sqlite, say I have the following :
>
> Base = declarative_base()
>
> class EventMessage(Base):
>       __tablename__ = 'event_message'
>       id=Column(Integer,primary_key=True)
>       sid=Column(Integer,primary_key=True)
>       text=Column(Text)
>
> class Event(Base):
>       __tablename__ = 'event'
>       id=Column(Integer,primary_key=True)
>       sid=Column(Integer,primary_key=True)
>        messageID=Column(Integer)
>        .... other indexed columns ...
>        message=relation(EventMessage,
>               primaryjoin=and_
> (Event
> .messageID==EventMessage.id,xperimentEvent.sid==EventMessage.sid),
>                        foreign_keys=[EventMessage.id,EventMessage.sid],
>                        uselist=False)
>
> I need the message text to be in a seperate table, because I am using
> a virtual table that has full text search enabled and I want the event
> table to maintain other indexes for performance.
>
> With the above code I can access an Event's message text via:
>
> myEvent.message.text
>
> How do I use Event.message.text as part of the filter for an Event
> query though? For example, I can not use:
>
> event.query().filter(Event.message.text.match('some text'))
>
> because I get an error stating that:
>
> 'RelationProperty' object has no attribute 'text'
>
>
> Does anybody know the proper way to do this?
>
> Thanks very much.
> >


--~--~---------~--~----~------------~-------~--~----~
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