Hi, I'm starting with SA so maybe I'm missing something.
I've checked the docs few times but I didn't find a solution.
I would like to have a many-to-many relation through a table.
I have Feeds they are related many-to-many with Categories and one-to-
many with FeedItems. I haven't found any reasonable solution for this.
Here is the code (only keys).
###
feeds_table = Table('feeds', meta,
Column('id', Integer(),primary_key=True),
)
feeditems_table = Table('feed_items', meta,
Column('id', Integer(), primary_key=True),
Column('feed_id', Integer(), ForeignKey('feeds.id')),
)
categories_table = Table('categories', meta,
Column('id', Integer(), primary_key=True),
)
feedscategories_table = Table('feeds_categories', meta,
Column('feed_id', Integer(), ForeignKey('feeds.id')),
Column('category_id', Integer(), ForeignKey('categories.id'))
)
feeds_mapper = assign_mapper(session_context, Feed, feeds_table,
properties = {
'feeditems' : relation(FeedItem, backref='feed')
}
)
categories_mapper = assign_mapper(session_context, Category,
categories_table, properties = {
'feeds' : relation(Feed, secondary=feedscategories_table,
lazy=False, backref='categories')
}
)
feeditems_mapper = assign_mapper(session_context, FeedItem,
feeditems_table
#,properties = { 'categories' :
relation(????, lazy=False, backref='feeditems') }
###
I know how to do it when the "through" table is in one-to-many
relation with primaryjoin, secondary and secondary join. But I have no
clue how to do it in this situation.
Second thing: do you plan to add Feed.select_by(title=['first',
'second']) as an option? I know i can use and_(table.c.title="first,
table.c.title="second").
This feature would be convenient (maybe there is a better way that I
don't know about).
Thanks in advance.
--
Regards
Adam Hoscilo
http://hoscilo.pypla.net
http://blog.bootstrap.pl
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---