Ticket #35 (closed defect: fixed)

Opened 2 years ago

Last modified 1 month ago

bug with getDefaultValue for table Field

Reported by: joaofernandes@… Owned by: bbowden
Type: defect Priority: normal
Milestone: Component: Reactor - Core Framework
Version: 1.0 Severity: normal
Keywords: getXML Field defaultValue Cc:

Description

I’m using reactorFactory.getxml() to build my custom plugins but reactor is failing on a specific table where I have a default value.

I debugged it and the problem is on the ObjectDao when calling

<cfset Field.default = getDefault(qFields.default, Field.cfDataType, Field.nullable) />

Which if I dump at the end the Field Object I have for default value: [undefined struct element]

Change History

Changed 2 years ago by dhughes

Can you please provide an example? I can’t reproduce.

Changed 2 years ago by dhughes

  • milestone changed from Release Candidate 2 (RC2) to Beta

Changed 2 years ago by dhughes

  • severity changed from critical to normal

Changed 2 years ago by bbowden

  • owner changed from dhughes to bbowden

Jaoa provided this additional info:

Hi there Beth,

I found out a mail with the solution for bug 35# , I knew that someone already posted it somewhere…

Regards,

João Fernandes
Dep. Informática - Área de Desenvolvimento
Cofina media

Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL
Tel (+351) 213 185 200 . Fax (+351) 213 540 370
joaofernandes@cofina.pt

From: lsitmanager@doughughes.net lsitmanager@doughughes.net On Behalf Of Doug Arthur
Sent: quinta-feira, 13 de Julho de 2006 17:36
To: reactor@reactorframework.com
Subject: [Reactor for CF] Bug in reactor.data.mssql.ObjectDao

I found a bug in the file listed in the subject. The getDefault() method does not return a proper value when typeName is a string and the database actually has a default value. It was missing the cfreturn tag in the esleif statement... This new cfreturn should become line 125 of ObjectDao.cfc in the reactor\data\mssql folder.


<!--- insure that the first and last characters are "'" --->

<cfif ReFindNoCase("'*newId()'*", arguments.sqlDefaultValue)>

<cfreturn "##CreateUUID()##" />
<!--- IS "newId()" --->

<cfelseif Left(arguments.sqlDefaultValue, 1) IS "'" AND Right(arguments.sqlDefaultValue, 1) IS "'">

<!--- mssql functions must be constants. for this reason I can convert anything quoted in single quotes safely to a string --->
<cfset arguments.sqlDefaultValue = Mid(arguments.sqlDefaultValue, 2, Len(arguments.sqlDefaultValue)-2) />
<cfset arguments.sqlDefaultValue = Replace(arguments.sqlDefaultValue, "", "'", "All") />
<cfset arguments.sqlDefaultValue = Replace(arguments.sqlDefaultValue, """", """""", "All") />
<cfreturn arguments.sqlDefaultValue /> <!--- This line was missing!!! --->

<cfelse>

<cfreturn "" />

</cfif>

Without that line there, this is the error that is produced:


Element FIELD.DEFAULT is undefined in ARGUMENTS.


The error occurred in D:\inetpub\daaroot\reactor\core\object.cfc: line 341
Called from D:\inetpub\daaroot\reactor\core\object.cfc: line 263
Called from D:\inetpub\daaroot\reactor\core\objectTranslator.cfc: line 22
Called from D:\inetpub\daaroot\reactor\core\objectFactory.cfc: line 121
Called from D:\inetpub\daaroot\reactor\reactorFactory.cfc: line 26
Called from D:\inetpub\daaroot\reactor\util\ReactorCompiler.cfc: line 57
Called from D:\inetpub\daaroot\compiler.cfm: line 3

339 : <cfset xmlField.XmlAttributescfSqlType? = arguments.field.cfSqlType />

340 : <cfset xmlField.XmlAttributeslength? = arguments.field.length />

341 : <cfset xmlField.XmlAttributesdefault? = arguments.field.default />

342 : <cfset xmlField.XmlAttributesobject? = arguments.config.object.XmlAttributes.name />

343 : <cfset xmlField.XmlAttributessequence? = arguments.field.sequenceName />

Here is a dump of the structure in which arguments.field was and the evidence that getDefault method is not returning a proper value.

struct

CFDATATYPE


string

CFSQLTYPE


cf_sql_char

DBDATATYPE


char

DEFAULT


[undefined struct element]

IDENTITY


false

LENGTH


1

NAME


pass_expires

NULLABLE


true

PRIMARYKEY


false

SEQUENCENAME


[empty string]

Changed 2 years ago by bbowden

  • status changed from new to closed
  • resolution set to fixed

Previously fixed

Changed 1 month ago by anonymous

  • milestone deleted

Milestone Beta deleted

Note: See TracTickets for help on using tickets.