You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Will Holcomb <wi...@himinbi.org> on 2002/12/18 05:31:16 UTC

[SOURCE] Issue #TRQS99 - Error setting default on foreign key

You can view the issue detail at the following URL:
<http://scarab.werken.com/scarab/issues/id/TRQS99>

Type :        Patch
Issue Id :    TRQS99
Reported by: Will Holcomb
             wholcomb - (will@himinbi.org)

Details:

Platform: PC
Operating system: Redhat
Summary: Error setting default on foreign key
Description: Object.vm includes the following code in the Object generation code when generating the methods to set a foreign key reference:

#if($colFK.Primitive)
  #set ($coldefval = "0")
  #set ($coldefval = $column.DefaultValue)
  set${column.JavaName}($coldefval);
#else
  set${column.JavaName}(($column.JavaNative)null);
#end

The template is checking here if the column being referred to is represented by an object and choosing how to set the default.

It is setting the default on the local column though, so the check should be whether the local column is an object, not the reffered to column.

The bulk of this patch is a change to this:

#if($localCol.primitive)
  #set( $defaultValue = 0 )
  ## Velocity will not assign when the returned value is null
  #set( $defaultValue = $column.defaultValue )
  set${column.javaName}($defaultValue);
#else
  set${column.javaName}(($column.javaNative)null);
#end

There is also some variable renaming within the local code block to make the logic clearer. (I did it while I was figuring out how it worked.)
Status: New
Priority: Medium
Vote: Medium