On Feb 24, 2006, at 8:57 AM, Brad Clements wrote:
> Is now better done this way::
>
>      class Foo(SQLObject):
>          other_id = IntCol()
>          other = Reference('Other', 'other_id')

In the case of compound keys, it'd be better to explicitly indicate the mapping between columns.

Compound keys will look like:

class Foo(SQLObject):
    id = ('fname', 'lname')
    fname = StringCol()
    lname = StringCol()

Then aFoo.id will return a tuple, and if Foo.id (the same in meaning as SQLObject 0.x's Foo.q.id) will cause any comparisons to be unpacked into two comparisons ANDed together.

How about using keywords in Reference to explicitely state the columns in the other table to be used in the join:

      class Foo(SQLObject):
          other_id1 = IntCol()
          other_name = StringCol()
          other = Reference('Other', id='other_id', name='other_name')

I have use cases where, say for individual record manipulation I have to use the compound primary key. But in other cases I only need to join based on one of the columns in the primary key. I'd like to be able to specify "other" both ways...

Yeah, that looks pretty straight-forward, I think.

--
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to