On Sep 26, 2008, at 2:42 PM, Steven wrote:

>
> Sorry for being the newbie.. i just tried the "many-to-many" example
> that you provided:
>
> records =
> meta.Session.query(func.count("*").label('cnt'),
> model
> .Tag
> ).filter
> (model.Tag.id==model.pagetag_table.c.tagid).group_by(model.Tag.name,
> model.Tag.id).order_by(model.Tag.name.asc())
>
> ======================
> as well as:
>
>        stmt = meta.Session.query(model.pagetag_table.c.tagid,
> func.count('*').label('page_count'))\
> .group_by(model.pagetag_table.c.tagid).subquery()
>
>        records = meta.Session.query(model.Tag,
> stmt.c.page_count).join((stmt, model.Tag.id == stmt\
> .c.tagid)).order_by(model.Tag.id)
>
> ======================
> both of which seem to throw this exception:
>
> "This operation requires a Query against a single mapper."
>
> Probably a newbie error on my part.... any ideas?

That exact error would only occur if you attempted to call query.get()  
or query.count() on any of those Query objects, which I dont see in  
any of your examples above, so perhaps the exception is being raised  
from elsewhere.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to