From 04ea58e273ffeac769c70760af91ab5aff335f28 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 29 Oct 2005 02:37:46 +0000 Subject: [PATCH] --- doc/build/content/datamapping.myt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/build/content/datamapping.myt b/doc/build/content/datamapping.myt index 1caed058ba..b4801bdf63 100644 --- a/doc/build/content/datamapping.myt +++ b/doc/build/content/datamapping.myt @@ -245,9 +245,13 @@ INSERT INTO article_keywords (article_id, keyword_id) VALUES (:article_id, :keyw [{'keyword_id': 1, 'article_id': 1}, {'keyword_id': 2, 'article_id': 1}] - # select articles based on some keywords. the extra selection criterion - # won't get in the way of the separate eager load of all the article's keywords - articles = Article.mapper.select(sql.and_(keywords.c.keyword_id==itemkeywords.c.keyword_id, itemkeywords.c.article_id==articles.c.article_id, keywords.c.name.in_('politics', 'entertainment'))) <&|formatting.myt:codepopper, link="sql" &> + # select articles based on some keywords. to select against joined criterion, we specify the + # join condition explicitly. the tables in the extra joined criterion + # will be given aliases at the SQL level so that they don't interfere with those of the JOIN + # already used for the eager load. + articles = Article.mapper.select(sql.and_(keywords.c.keyword_id==itemkeywords.c.keyword_id, + itemkeywords.c.article_id==articles.c.article_id, + keywords.c.name.in_('politics', 'entertainment'))) <&|formatting.myt:codepopper, link="sql" &> SELECT articles.article_id AS articles_article_id, articles.article_headline AS articles_article_headline, articles.article_body AS articles_article_body, -- 2.47.2