Hi, since the 0.3.7 release a great feature of many to many relationships disappeared. The following code refers to the Wiki example for many to many relationships. With 0.3.6 I could either write
session.query(Article).select_by(keywords=politics) (where 'politics' is the object representing the politics keyword) or write session.query(Article).select_by(keyword_name="politics") With 0.3.7 only the second approach works. Is there an easy way to get both mappings work again? There was some discussion about a related issue in the "Issue using rev 2425" thread - but the solution seemed quite complicated. The following python script (a slightly modified version of the wiki example) demonstrates the problem. Regards, David from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData() articles_table = Table('articles', metadata, Column('article_id', Integer, primary_key = True), Column('headline', String(150), key='headline'), Column('body', TEXT, key='body'), ) keywords_table = Table('keywords', metadata, Column('keyword_id', Integer, primary_key = True), Column('keyword_name', String(50)) ) itemkeywords_table = Table('article_keywords', metadata, Column('article_id', Integer, ForeignKey("articles.article_id")), Column('keyword_id', Integer, ForeignKey("keywords.keyword_id")) ) engine = create_engine('sqlite:///') metadata.create_all(engine) class Keyword(object): def __init__(self, name): self.keyword_name = name class Article(object): pass mapper(Keyword, keywords_table) mapper(Article, articles_table, properties = dict( keywords = relation(Keyword, secondary=itemkeywords_table, lazy=False) ) ) session = create_session(bind_to=engine) politics = Keyword('politics') entertainment = Keyword('entertainment') article = Article() article.headline = 'a headline' article.body = 'this is the body' article.keywords.append(politics) article.keywords.append(entertainment) session.save(article) session.flush() print session.query(Article).select_by(keyword_name="politics") print session.query(Article).select_by(keywords=politics) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---