diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-26 00:04:43 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-26 00:04:43 +0000 |
| commit | aadd46c5fdd1d9af9b2f886a22dce4ab172f961b (patch) | |
| tree | 18c7a66f07f5ad0d5919882eb27c326a191ec0ab /doc | |
| parent | fdf9292241e22eb464c366bcf69c0212b3ff4c41 (diff) | |
| download | sqlalchemy-aadd46c5fdd1d9af9b2f886a22dce4ab172f961b.tar.gz | |
fixed many-to-many example, which was utterly incorrect in many ways
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/build/content/datamapping.myt | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/build/content/datamapping.myt b/doc/build/content/datamapping.myt index acaad8026..16ec1ace2 100644 --- a/doc/build/content/datamapping.myt +++ b/doc/build/content/datamapping.myt @@ -619,7 +619,7 @@ VALUES (:address_id, :user_id, :email_address) keywords = Table('keywords', engine, Column('keyword_id', Integer, primary_key = True), - Column('name', String(50)) + Column('keyword_name', String(50)) ) itemkeywords = Table('article_keywords', engine, @@ -630,7 +630,7 @@ VALUES (:address_id, :user_id, :email_address) # class definitions class Keyword(object): def __init__(self, name = None): - self.name = name + self.keyword_name = name class Article(object): pass @@ -638,7 +638,7 @@ VALUES (:address_id, :user_id, :email_address) # define a mapper that does many-to-many on the 'itemkeywords' association # table Article.mapper = mapper(Article, articles, properties = dict( - keywords = relation(mapper(Keyword, keywords), keywords, itemkeywords, lazy=False) + keywords = relation(mapper(Keyword, keywords), itemkeywords, lazy=False) ) ) @@ -666,7 +666,7 @@ 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 a keyword. select_by will handle the extra joins. - <&formatting.myt:poplink&>articles = Article.mapper.select_by(keyword='politics') + <&formatting.myt:poplink&>articles = Article.mapper.select_by(keyword_name='politics') <&|formatting.myt:codepopper, link="sql" &> SELECT articles.article_id AS articles_article_id, articles.article_headline AS articles_article_headline, |
