Next time send your questions to the mailing list, please.
The correct query is:
items = Item.select(
Tag.q.term == tag,
join=(LEFTJOINOn(Item, ItemTag, Item.q.id == ItemTag.q.itemID),
LEFTJOINOn(Tag, ItemTag, Tag.q.id == ItemTag.q.tagID))
)
On Wed, Apr 18, 2007 at 04:25:11PM -0400, Fred C wrote:
> items = Item.select(
> Tag.q.term == tag,
> LEFTJOINOn(Item, ItemTag, Item.q.id == ItemTag.q.item_id),
> LEFTJOINOn(Tag, ItemTag, Tag.q.id == ItemTag.q.tag_id)
> )
>
> And I have these objects.
>
>
> class Item(SQLObject):
> class sqlmeta:
> defaultOrder = "-updated"
>
> itemhash = StringCol(length=34, alternateID=True,
> alternateMethodName="byItemhash")
> link = StringCol(length=512, alternateID=True,
> alternateMethodName='byLink')
> title = UnicodeCol(length=96)
> category = IntCol(default=0)
>
> tags = SQLRelatedJoin('Tag', intermediateTable='item_tag',
> createRelatedTable=False,
> joinColumn='item_id', otherColumn='tag_id')
>
> class Tag(SQLObject):
> term = StringCol(length=64)
> category = IntCol(default=0);
> date_in = DateTimeCol(default=datetime.now)
>
> items = SQLRelatedJoin('Item', intermediateTable='item_tag',
> createRelatedTable=False,
> joinColumn='tag_id', otherColumn='item_id')
>
> class ItemTag(SQLObject):
> class sqlmeta:
> table = "item_tag"
>
> item = ForeignKey('Item', notNull=True, cascade=True)
> tag = ForeignKey('Tag', notNull=True, cascade=True)
> unique = index.DatabaseIndex(item, tag, unique=True)
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss