Ticket #193 (closed defect: fixed)

Opened 20 years ago

Last modified 19 years ago

Scaffolds behaving weirdly with linking table in MySQL5

Reported by: tombishop Owned by: simeon
Priority: high Milestone:
Version: Severity: normal
Keywords: Cc:

Description

I'm getting the following error when trying to scaffold a link object (not sure if it's supposed to be possible but can't see why not).

Have got 3 tables:

1. booking - bookingid (int, pk, increment), date (datetime) 2. table - tableid (int, pk, increment), tablename (varchar) 3. bookingtable - bookingtableid (int, pk, increment), bookingid (int), tableid (int)

Have defined their relationships in Reactor.xml:

<object name="booking">

<hasMany name="table"><link name="bookingtable"></link></hasMany>

</object>

<object name="table">

<hasMany name="booking"><link name="bookingtable"></link></hasMany>

</object>

<object name="bookingtable">

<hasOne name="booking"><relate from="bookingid" to="bookingid"></relate></hasOne> <hasOne name="table"><relate from="tableid" to="tableid"></relate></hasOne>

</object>

However, when I run the following scaffold I get an error:

<scaffold object="bookingtable" />

The error:

The element at position 4 of dimension 1, of array variable "FIELDS," cannot be found.

The error occurred in C:\CFusionMX7\wwwroot\ModelGlue?\unity\orm\ReactorAdapter?.cfc: line 78 Called from C:\CFusionMX7\wwwroot\ModelGlue?\unity\eventhandler\EventHandlerFactory?.cfc: line 28 Called from C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc: line 345 Called from C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc: line 49 Called from C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\FrameworkLoader?.cfc: line 63 Called from C:\CFusionMX7\wwwroot\ModelGlue?\unity\ModelGlue?.cfm: line 48 Called from C:\CFusionMX7\wwwroot\RestaurantWebApp?\index.cfm: line 50

76 : </cfloop> 77 : <cfif not len(result.labelField)> 78 : <cfset result.labelField = fields[i].alias /> 79 : </cfif> 80 :

Resources:

  • Check the ColdFusion? documentation to verify that you are using the correct syntax.
  • Search the Knowledge Base to find a solution to your problem.

Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 Remote Address 127.0.0.1 Referrer http://localhost:8500/restaurantwebapp/index.cfm?event=booking.list Date/Time 18-Aug-06 06:19 PM Stack Trace at cfReactorAdapter2ecfc848123354$funcGETOBJECTMETADATA.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\orm\ReactorAdapter?.cfc:78) at cfEventHandlerFactory2ecfc1537087051$funcCREATE.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\eventhandler\EventHandlerFactory?.cfc:28) at cfXmlConfigurationLoader2ecfc2026726242$funcLOADEVENTHANDLERS.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc:345) at cfXmlConfigurationLoader2ecfc2026726242$funcLOAD.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc:49) at cfFrameworkLoader2ecfc40625765$funcLOAD.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\FrameworkLoader?.cfc:63) at cfModelGlue2ecfm1740822030.runPage(C:\CFusionMX7\wwwroot\ModelGlue?\unity\ModelGlue?.cfm:48) at cfindex2ecfm378213407.runPage(C:\CFusionMX7\wwwroot\RestaurantWebApp?\index.cfm:50)

coldfusion.runtime.CfJspPage?$ArrayBoundException?: The element at position 4 of dimension 1, of array variable &quot;FIELDS,&quot; cannot be found.

at coldfusion.runtime.CfJspPage?.ArrayGetAt?(CfJspPage?.java:467) at coldfusion.runtime.CfJspPage?._arrayGetAt(CfJspPage?.java:516) at coldfusion.runtime.CfJspPage?._arrayGetAt(CfJspPage?.java:416) at cfReactorAdapter2ecfc848123354$funcGETOBJECTMETADATA.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\orm\ReactorAdapter?.cfc:78) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter?.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter?.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter?.invoke(FunctionAccessFilter?.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:194) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:146) at coldfusion.runtime.CfJspPage?._invoke(CfJspPage?.java:1634) at cfEventHandlerFactory2ecfc1537087051$funcCREATE.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\eventhandler\EventHandlerFactory?.cfc:28) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter?.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter?.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter?.invoke(FunctionAccessFilter?.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:194) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:146) at coldfusion.runtime.CfJspPage?._invoke(CfJspPage?.java:1634) at cfXmlConfigurationLoader2ecfc2026726242$funcLOADEVENTHANDLERS.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc:345) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter?.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter?.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter?.invoke(FunctionAccessFilter?.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.CfJspPage?._invokeUDF(CfJspPage?.java:1807) at cfXmlConfigurationLoader2ecfc2026726242$funcLOAD.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\XmlConfigurationLoader?.cfc:49) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter?.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter?.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter?.invoke(FunctionAccessFilter?.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:194) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:146) at coldfusion.runtime.CfJspPage?._invoke(CfJspPage?.java:1634) at cfFrameworkLoader2ecfc40625765$funcLOAD.runFunction(C:\CFusionMX7\wwwroot\ModelGlue?\unity\loader\FrameworkLoader?.cfc:63) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter?.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter?.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter?.invoke(FunctionAccessFilter?.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:194) at coldfusion.runtime.TemplateProxy?.invoke(TemplateProxy?.java:146) at coldfusion.runtime.CfJspPage?._invoke(CfJspPage?.java:1634) at cfModelGlue2ecfm1740822030.runPage(C:\CFusionMX7\wwwroot\ModelGlue?\unity\ModelGlue?.cfm:48) at coldfusion.runtime.CfJspPage?.invoke(CfJspPage?.java:152) at coldfusion.tagext.lang.IncludeTag?.doStartTag(IncludeTag?.java:349) at coldfusion.runtime.CfJspPage?._emptyTag(CfJspPage?.java:1915) at cfindex2ecfm378213407.runPage(C:\CFusionMX7\wwwroot\RestaurantWebApp?\index.cfm:50) at coldfusion.runtime.CfJspPage?.invoke(CfJspPage?.java:152) at coldfusion.tagext.lang.IncludeTag?.doStartTag(IncludeTag?.java:349) at coldfusion.filter.CfincludeFilter?.invoke(CfincludeFilter?.java:65) at coldfusion.filter.ApplicationFilter?.invoke(ApplicationFilter?.java:225) at coldfusion.filter.RequestMonitorFilter?.invoke(RequestMonitorFilter?.java:51) at coldfusion.filter.PathFilter?.invoke(PathFilter?.java:86) at coldfusion.filter.LicenseFilter?.invoke(LicenseFilter?.java:27) at coldfusion.filter.ExceptionFilter?.invoke(ExceptionFilter?.java:69) at coldfusion.filter.ClientScopePersistenceFilter?.invoke(ClientScopePersistenceFilter?.java:28) at coldfusion.filter.BrowserFilter?.invoke(BrowserFilter?.java:38) at coldfusion.filter.GlobalsFilter?.invoke(GlobalsFilter?.java:38) at coldfusion.filter.DatasourceFilter?.invoke(DatasourceFilter?.java:22) at coldfusion.filter.RequestThrottleFilter?.invoke(RequestThrottleFilter?.java:115) at coldfusion.CfmServlet?.service(CfmServlet?.java:107) at coldfusion.bootstrap.BootstrapServlet?.service(BootstrapServlet?.java:78) at jrun.servlet.ServletInvoker?.invoke(ServletInvoker?.java:91) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257) at jrun.servlet.ServletEngineService?.dispatch(ServletEngineService?.java:541) at jrun.servlet.http.WebService?.invokeRunnable(WebService?.java:172) at jrunx.scheduler.ThreadPool?$DownstreamMetrics?.invokeRunnable(ThreadPool?.java:318) at jrunx.scheduler.ThreadPool?$ThreadThrottle?.invokeRunnable(ThreadPool?.java:426) at jrunx.scheduler.ThreadPool?$UpstreamMetrics?.invokeRunnable(ThreadPool?.java:264) at jrunx.scheduler.WorkerThread?.run(WorkerThread?.java:66)

Perhaps I'm doing something wrong. However, I've followed the example in the documentation and have checked/rechecked.

Cheers, Tom

Change History

follow-up: ↓ 2   Changed 20 years ago by simeon

I am having a similar problem, but I am using mysql4. The problem also only occurs on linux, maybe unrelated, but it works on my mac and on windows.

in reply to: ↑ 1   Changed 20 years ago by simeon

  • owner changed from somebody to simeon
  • status changed from new to assigned

Replying to simeon:

I am having a similar problem, but I am using mysql4. The problem also only occurs on linux, maybe unrelated, but it works on my mac and on windows.

OK here is the rub. Does the hasMany table have any fields that are type string? I found the problem in mine, and its looking for the first column that is a string to use as display, but it doesnt have any so its looping too far.

  Changed 20 years ago by simeon

Ok, I figured it out.

From /ModelGlue/unity/orm/ReactorAdaptor.cfc Lines 71-19 <cfloop from="1" to="#arrayLen(fields)#" index="i">

<cfif fields[i].cfdatatype eq "string">

<cfset labelField = fields[i].alias> <cfbreak />

</cfif>

</cfloop> <cfif not len(result.labelField)>

<cfset result.labelField = fields[i].alias />

</cfif>

If the table doesnt have any fields of type "string" then when it exits i = arrayLen(fields) + 1, because of the final evaluation of the loop. Therefore when it sees nothing was set and it sets the labelfield ot fields[i].alias i is one more than the biggest index of the array and it errors.

I suggest changing the i to a 1 (one) so it will just use the first field. Also in the loop the value should probably be result.labelField.

I have verified this solution on my mac and linux, both using mysql 4.1

  Changed 19 years ago by joe.rinehart

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

Fixed in [217]

Note: See TracTickets for help on using tickets.