db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Baker" <gary.ba...@movielink.com>
Subject [PATCH] RE: Tables with foreign keys to themselves don't maintain Lists of related rows.
Date Wed, 24 Sep 2003 18:26:32 GMT
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... 

	>	<table name="XXX">
	>	        <column name="XXX_ID" type="VARCHAR" size="40"
	>	        <column name="SUPER_ID" type="VARCHAR"
	>	        <foreign-key foreignTable="XXX">
	>	            <reference local="SUPER_ID"
	>	        </foreign-key>
	>	</table>

	>	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?

	>	Thanks,
	>	-Gary

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.


View raw message