Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Ian Bicking <ianb <at> colorstudy.com>
Subject: Re: Filtering SQLRelatedJoin results
Newsgroups: gmane.comp.python.sqlobject
Date: Saturday 19th November 2005 21:09:40 UTC (over 11 years ago)
Steve Zatz wrote:
> I realize that this may be unintelligible but here goes anyway:
> 
> The structure of the database is:
> 
> class Item(SQLObject):
>    title= StringCol(length=75)
>    section = ForeignKey('Section')
>    categories = SQLRelatedJoin('Category')
> 
> class Category(SQLObject):
>    name = StringCol(length=20, alternateID=True)
>    items = SQLRelatedJoin('Item')
> 
> class Section(SQLObject):
>    name = StringCol(length=20, alternateID=True)
>    items = SQLMultipleJoin('Item')
> 
> If I do the following:
> 
> Category.byName('cat1').items.filter(Item.q.sectionID == 2)
> 
> The following is generated:
> 
> 1/QueryR  :  SELECT item.id, item.title, item.section_id FROM
> category, item, category_item WHERE ('item.id = category_item.item_id
> and
> category_item.category_id = category.id and
> category.id = 1' AND (item.section_id = 2))

I looks like SQLRelatedJoin is creating a text query, not a SQLBuilder
query.  I guess there's a couple ways that could be fixed:

* SQLRelatedJoin could generate a SQLBuilder query
* AND could turn strings passed into it into SQLBuilder expressions
* .filter() could turn previous string-based queries into SQLBuilder
expressions.

Probably the last one is best.  I'll look into that.


-- 
Ian Bicking  |  [email protected]  |  http://blog.ianbicking.org


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
 
CD: 17ms