[orm-devel] Bug or feature in relationships.py

Ross J. Reedstrom orm-devel@mailman.tux4web.de
Mon, 17 Feb 2003 16:52:29 -0600


On Mon, Feb 17, 2003 at 01:17:49PM -0800, Michael Watkins wrote:
> Greetings all -
> 
> Warning, its been a little while since I last dug about in ORM so if I 
> sound a little off base or deranged, please forgive me in advance. I may 
> just need a gentle nudge here.
> 
> I had to dust off some web-forms code I wrote a while ago using ORM and 
> just realized (I think) that there is a bug, or a misunderstood (on my 
> part) feature in how the one2one relationship is implemented.
> 
> In reading my old code it looks like I set a "lookup" relationship between 
> a parent object (say a document) and a status object (a small table of 
> status items). When you change an existing parent object by reassigning a 
> different status object, the change is made but the net effect is the row 
> from the status table is deleted.

What you describe below is not a 1:1 relationship, but a n:1 (many to
one) - more than one row in the Document table shares the same Status
id, therefore it is not one to one. This is a common pattern, often
used exactly as you did, to map codes to larger descriptions. I'm not
sure this is currently supported in ORM (but it should be ;-) since you
can't really use one2many backwards, like you would in a generic SQL
schema description. 

Ross