I have 2 tables who look like that.
class Tag(SQLObject):
term = StringCol(length=64)
category = IntCol(default=0);
date_in = DateTimeCol(default=datetime.now)
items = RelatedJoin('Item', intermediateTable='item_tag',
joinColumn='tag_id', otherColumn='item_id')
class Item(SQLObject):
itemhash = StringCol(length=34, alternateID=True,
alternateMethodName="byItemhash")
link = StringCol(length=512, alternateID=True,
alternateMethodName='byLink')
title = UnicodeCol(length=96)
summary = UnicodeCol(length=512)
updated = DateTimeCol(default=datetime.now)
relations_updated = DateTimeCol(default=datetime.now)
category = IntCol(default=0)
tags = RelatedJoin('Tag', intermediateTable='item_tag',
joinColumn='item_id', otherColumn='tag_id')
And I would like to do a request like this.
items = Item.select(
Tag.q.term == tag,
LEFTJOINOn(Item, item_tag, Item.q.id == item_id),
LEFTJOINOn(Tag, item_tag, Tag.q.id == tag_id)
)
#SELECT * FROM item_tag LEFT JOIN tag ON tag_id = tag.id LEFT JOIN
item ON item.id = item_id
#WHERE tag.term='apple';
The problem is, I don't have a class for the table item_tag and I
don't know how to address it.
Thanks for any solutions
-fred-
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss