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 FW: [PATCH] RE: Tables with foreign keys to themselves don't maintain Lists of related rows.
Date Fri, 24 Oct 2003 17:50:57 GMT
Ola! - Anyone wanna patch this for me?
It's quite useful.


-----Original Message-----
From: Gary Baker 
Sent: Wednesday, September 24, 2003 11:27 AM
To: 'torque-dev@db.apache.org'
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... 

	>	<table name="XXX">
	>	        <column name="XXX_ID" type="VARCHAR" size="40"
primaryKey="true"/>
	>	        <column name="SUPER_ID" type="VARCHAR"
size="40"/>
	>	        <foreign-key foreignTable="XXX">
	>	            <reference local="SUPER_ID"
foreign="XXX_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.

Regards,
-Gary





Mime
View raw message