summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/build/content/datamapping.myt25
1 files changed, 12 insertions, 13 deletions
diff --git a/doc/build/content/datamapping.myt b/doc/build/content/datamapping.myt
index 16ec1ace2..35493247c 100644
--- a/doc/build/content/datamapping.myt
+++ b/doc/build/content/datamapping.myt
@@ -734,24 +734,23 @@ INSERT INTO article_keywords (article_id, keyword_id) VALUES (:article_id, :keyw
pass
# mapper for KeywordAssociation
- KeywordAssociation.mapper = mapper(KeywordAssociation, itemkeywords)
-
- # mappers for Users, Keywords
- User.mapper = mapper(User, users)
- Keyword.mapper = mapper(Keyword, keywords)
-
- # define the mapper. when we load an article, we always want to get the keywords via
- # eager loading. but the user who added each keyword, we usually dont need so specify
- # lazy loading for that.
- m = mapper(Article, articles, properties=dict(
- keywords = relation(KeywordAssociation.mapper, lazy=False, association=Keyword,
+ # specify "primary key" columns manually
+ KeywordAssociation.mapper = mapper(KeywordAssociation, itemkeywords,
primary_key = [itemkeywords.c.article_id, itemkeywords.c.keyword_id],
properties={
'keyword' : relation(Keyword, lazy = False), # uses primary Keyword mapper
'user' : relation(User, lazy = True) # uses primary User mapper
}
- )
- )
+ )
+
+ # mappers for Users, Keywords
+ User.mapper = mapper(User, users)
+ Keyword.mapper = mapper(Keyword, keywords)
+
+ # define the mapper.
+ m = mapper(Article, articles, properties={
+ 'keywords':relation(KeywordAssociation.mapper, lazy=False, association=Keyword)
+ }
)
# bonus step - well, we do want to load the users in one shot,