[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Stodge
Ok so far I have this: expressions = [] for tag in tag_list: expressions += session.query(Document).filter(Tag.tag==tag) documents = session.query(Document).join(Document.tags).filter(and_(*expressions)) Doesn't work but it's progress! :) On Mar 18, 2:37 pm, Stodge sto...@gmail.com

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Stodge
Now we're getting somewhere: expressions = [] for tag in tag_list: expressions += [Tag.tag==tag] documents = session.query(Document).join(Document.tags).filter(and_(*expressions)) Thanks to a Storm example I found. :) On Mar 19, 8:12 am, Stodge sto...@gmail.com wrote: Ok so far I have

Re: [sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Michael Bayer
select document.* from document join tags on document.id=tags.document_id where tags.tag='foo' and tags.tag='bar' and tags.tag= am I missing something ? that would return no rows in most cases. if you want to find documents that have an exact list of tags, you'd have to do something like

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Stodge
Thanks. That doesn't quite work. Based on my data, the following should (and does) work because it only returns document id=1, which only has these two tags: tag_list = ['my document', 'source code'] session.query(Document).\ filter(Document.tags.any(Tag.tag.in_([t for t in tag_list]))).\

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Stodge
Getting closer. Maybe something like this: q1 = session.query(Document).join(Document.tags).filter(Tag.tag=='my document') q2 = session.query(Document).join(Document.tags).filter(Tag.tag=='source code') q3 = q1.intersect(q2) q4 = session.query(Document).filter(Document.title=='Source Code') print

Re: [sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Conor
Stodge wrote: Thanks. That doesn't quite work. Based on my data, the following should (and does) work because it only returns document id=1, which only has these two tags: tag_list = ['my document', 'source code'] session.query(Document).\ filter(Document.tags.any(Tag.tag.in_([t for t

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-19 Thread Stodge
Thanks! That worked beautifully. :) On Mar 19, 11:18 am, Conor conor.edward.da...@gmail.com wrote: Stodge wrote: Thanks. That doesn't quite work. Based on my data, the following should (and does) work because it only returns document id=1, which only has these two tags: tag_list = ['my

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-18 Thread Stodge
Thanks that worked beautifully. On a similar note, how would I match documents with only the tags that I specify in the list? My naive attempt is: for tag in tag_list: session.query(Document).join(Document.tags).filter_by(tag=tag) But that doesn't work. On Mar 15, 10:54 am, Michael Bayer

[sqlalchemy] Re: in_() operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-15 Thread Stodge
Thanks. I wrote the error message from memory, the exact wording is: session.query(Document).filter(Document.tags.in_(tag_list)) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.6/site-packages/sqlalchemy/sql/ expression.py, line 1274, in in_ return