From: Ian B. <ia...@co...> - 2006-02-28 03:09:16
|
On Feb 24, 2006, at 8:57 AM, Brad Clements wrote: > > Is now better done this way:: > > > >=A0=A0=A0=A0=A0 class Foo(SQLObject): > >=A0=A0=A0=A0=A0=A0=A0=A0=A0 other_id =3D IntCol() > >=A0=A0=A0=A0=A0=A0=A0=A0=A0 other =3D Reference('Other', 'other_id') > > In the case of compound keys, it'd be better to explicitly indicate=20 > the mapping between columns. Compound keys will look like: class Foo(SQLObject): id =3D ('fname', 'lname') fname =3D StringCol() lname =3D StringCol() Then aFoo.id will return a tuple, and if Foo.id (the same in meaning as=20= SQLObject 0.x's Foo.q.id) will cause any comparisons to be unpacked=20 into two comparisons ANDed together. > How about using keywords in Reference to explicitely state the columns=20= > in the other table to be used in the join: > > =A0=A0=A0=A0=A0 class Foo(SQLObject): > =A0=A0=A0=A0=A0=A0=A0=A0=A0 other_id1 =3D IntCol() > =A0=A0=A0=A0=A0=A0=A0=A0=A0 other_name =3D StringCol() > =A0=A0=A0=A0=A0=A0=A0=A0=A0 other =3D Reference('Other', = id=3D'other_id', name=3D'other_name') > > I have use cases where, say for individual record manipulation I have=20= > to use the compound primary key. But in other cases I only need to=20 > join based on one of the columns in the primary key. I'd like to be=20 > able to specify "other" both ways... Yeah, that looks pretty straight-forward, I think. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |