Ola! - Anyone wanna patch this for me?
It's quite useful.
From: Gary Baker
Sent: Wednesday, September 24, 2003 11:27 AM
Subject: [PATCH] RE: Tables with foreign keys to themselves don't
maintain Lists of related rows.
I didn't get any feedback from the user list from this post, so I went
digging through the code.
Here's the post...
> I've got a table with a foreign key to itself.
> Shouldn't the BaseXXX class maintain a List of related
rows based on that foreign key...
> For example...
> Shouldn't there be a property on BaseXXX called collXxx
of type List?? (there isn't one)
> There are other tables with foreign keys to this table
and such Lists exist for those tables.
> I'm using version 3.1?
> Is this by design? Or is this a short-coming?
Here's what I found...
I found that there were if statements in Object.vm and
ObjectWithManager.vm that were bypassing the collections code when the
table of the foreign key was the same as the table of the context.
I removed these. I then found that the local foreign keys were using
the same naming convention as multiple foreign keys (i.e. suffixed with
"RelatedByXXX"). I went through and removed this code so that the
"local" foreign keys would not be suffixed in this way.
That solved the issue for me.
I have attached the patch for ObjectWithManager.vm (which is what I'm
using). If I'm missing the bigger picture, then please inform me. If
my changes are satisfactory, then I'd be willing to make the same
changes to Object.vm.