On Nov 16, 2010, at 3:56 PM, Alvaro Reinoso wrote:

> Hi all,
> 
> I have a problem when querying the database:
> 
> This channel class:
> 
> class Channel(rdb.Model):
>       """Represents both complex channels and trivial ones (media)"""
>       rdb.metadata(metadata)
>       rdb.tablename("channels")
> 
>       id = Column("id", Integer, primary_key=True)
>       title = Column("title", String(100))
>        ....
> 
>       items = relationship("MediaItem", secondary=channel_items,
> order_by="MediaItem.position", backref="channels")
> 
> I get the proper channel object if I do:
> 
>       channel = session.query(Channel).filter(Channel.title == title)

filter() always returns a Query object, not an instance.   So there is no 
difference here between the call above and the one on MediaGroup, as far as the 
return result being a Query.





> 
> And this is my mediaGroup class:
> 
> class MediaGroup(rdb.Model):
>       """Represents MediaGroup class. Contains channels and other media
> groups"""
>       rdb.metadata(metadata)
>       rdb.tablename("media_groups")
> 
>       id = Column("id", Integer, primary_key=True)
>       title = Column("title", String(100))
>       ....
> 
>       channels = relationship("Channel", secondary=media_group_channels,
> order_by="Channel.titleView", backref="media_groups")
>       mediaGroups = relationship("MediaGroup",
> secondary=media_group_groups, order_by="MediaGroup.title",
>               primaryjoin=lambda: MediaGroup.id ==
> media_group_groups.c.media_groupA_id,
>               secondaryjoin=lambda: MediaGroup.id ==
> media_group_groups.c.media_groupB_id,
>               backref="media_groups")
> 
> I get the Query object object if I do:
> 
>       mediaGroup = session.query(MediaGroup).filter(MediaGroup.title ==
> title)
> 
> I don't know if it's because of the relationships but I tried without
> mediaGroups relation, and I didn't work either.
> 
> Any idea??
> 
> Thanks!
> 
> -- 
> 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.
> 

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