Ticket #169 (closed defect: fixed)
Error in ReactorAdapter.cfc when there are no columns with a data type that is a string.
| Reported by: | scott@… | Owned by: | somebody |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Version: | Severity: | normal | |
| Keywords: | Cc: |
Description
If you are using Reactor for ORM, and you try to specify a table that does not have a column where the datatype is a string (like VARCHAR, CHAR, etc), you will get an error in ReactorAdapter?.cfc, line 78.
I am not sure why, but after this code from ReactorAdapter?.cfc Iline 70-76) is run:
<!--- Determine the "label" field --->
<cfloop from="1" to="#arrayLen(fields)#" index="i">
<cfif fields[i].cfdatatype eq "string">
<cfset labelField = fields[i].alias> <cfbreak />
</cfif>
</cfloop>
The value of 'i' actaully becomes one larger than arraylen(fields). You will notice that the loop gets broken only if a cfdatatype is equal to 'string'.
This causes an issue in the next block of code (line 77-79):
<cfif not len(result.labelField)>
<cfset result.labelField = fields[i].alias />
</cfif>
If the array 'fields' had 5 elements, then by the time <cfset result.labelField = fields[i].alias /> gets runs, 'i' would actaully have a value of 6, which throws an error.
By changing line 78 to <cfset result.labelField = fields[arrayLen(fields)].alias />, I was able to get around the error, and things seem to be working as expected.
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)