On Apr 28, 2007, at 2:58 AM, ml wrote:
>
> Hi!
>
> I have tables "recipes" and "recipes_ctgs" (M:N relation).
>
> Mappers:
>
> mapper(Recipe, recipes, order_by = desc(recipes.c.date))
> mapper(RecipesCtg, recipes_ctgs, order_by=recipes_ctgs.c.title,
> properties={
> "recipes": relation(Recipe, secondary=_recipes_ctgs_mid,
> lazy=True,
> order_by=desc(recipes.c.date),
> backref=backref("ctgs", lazy=True)),
> "children": relation(RecipesCtg, lazy=True, cascade="all",
> order_by=recipes_ctgs.c.title,
> backref=backref("parent", lazy=True,
> foreignkey=recipes_ctgs.c.id))
> }
> )
>
> A query
>
> q = self.wbr.db.query(Recipe).join("ctgs").distinct()
> q.count_by(RecipesCtg.c.id.in_(...))
>
> doesn't contain the join, result is:
>
> SELECT count(getcount.id) AS tbl_row_count
> FROM (SELECT DISTINCT recipes.id AS id, recipes.id_user AS id_user,
> recipes.title AS title, recipes.date AS date, recipes.text AS text,
> recipes.tsv AS tsv, recipes.cook_time AS cook_time, recipes.rating AS
> rating, recipes.rating_count AS rating_count, recipes.state AS state
> FROM recipes, recipes_ctgs
> WHERE recipes_ctgs.id IN (someids)) AS getcount
>
> Without the distinct() the join is present.
>
its probably a bug, and it would make my life easier if you could
just attach a full example, i.e. the mappers above plus some basic
Table defs and some placeholder classes....otherwise ill try to get
around to it soon.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---