Pau Aliagas wrote:

I have two tables:

class handset_brand(SQLObject):
        brand = StringCol(alternateID = True, length = 50)
        handsets = SQLMultipleJoin('handset')

class handset(SQLObject):
        handset_brand = ForeignKey('handset_brand')
        model = StringCol(alternateID = True, length = 25)


I want to query the handsets of one brand. This should be obvious, right?
Well, at least for me it isn't, it does not work as expected.
[snip]

handset_brands.get(4).handsets
is probably the simplest.

print handset.select(handset.q.handset_brandID==4)
SELECT handset.id_handset, handset.id_handset_brand, handset.model FROM handset WHERE (handset.id_handset_brand = 4)

This one works!

Conclusion: it is not obvious!
[snip]

It may not be trivial, but it is obvious once you read the sqlobject documentation. It is also necessary if you want to use a more complicated query involving an AND() or something.

--
- Justin



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to