Ticket #277 (closed defect: duplicate)

Opened 19 years ago

Last modified 19 years ago

Alias Problems Simplified

Reported by: Bryan S Owned by: somebody
Priority: highest Milestone:
Version: Severity: blocker
Keywords: Cc:

Description

This is a simplified version of Ticket #226 (closed defect: worksforme) which is not resolved for me. It is very easy for me to recreate two of the problems using the steps below:

I am using Model Glue 286 but I first started experiencing the problem last October.

1) In ModelGlue?.xml for any table create a scaffold event handler

<scaffold object="ZdemoTable?">

<results>

<result do="view.template" />

</results>

</scaffold>

2) In Reactor.xml create an object for the table. If you are not using Oracle you don't need the "sequence=".

<object name="ZDEMO_TABLE" alias="ZdemoTable?">

<field name="ZDT_ZDEMO_TABLE_ID" alias="ZdemoTableId?"

sequence="S_ZDEMO_TABLE" />

<field name="ZDT_COLUMN_ONE" alias="ColumnOne?" /> <field name="ZDT_COLUMN_TWO" alias="ColumnTwo?" />

</object>

3) Allow Model Glue to build the scaffold events in Scaffolds.xml http://localhost/YourApp/index.cfm?init=true&scaffold=true

4) Run the list event for the table and click on one of the view links under the column name headings. If you have the same problem that I am having you will get back an empty record.

5) Now go to your Scaffold.xml and you will see five references to the primary key (in my case ZDT_ZDEMO_TABLE_ID). Do a search and replace with the alias for the field (in my case ZdemoTableId?). Now you should get the record back.

6) Go back to the list and click the edit link for the record, make a change to the record, and click save. If you have the same problem that I am you will get an error below for the primary key get method. However, if you go back to the list you will see that your change was made.

The method 'getZDT_ZDEMO_TABLE_ID' could not be found in component D:\Inetpub\wwwroot\YourApp?\model\data\Record\ZdemoTableRecordoracle?.cfc. Detail Check to ensure that the method is defined, and that it is spelled correctly. Extended Info Tag Context D:\Inetpub\wwwroot\ModelGlue?\unity\controller\GenericORMController.cfc (143) D:\Inetpub\wwwroot\ModelGlue?\unity\listener\Listener.cfc (26) D:\Inetpub\wwwroot\ModelGlue?\unity\eventrequest\MessageBroadcaster?.cfc (32) D:\Inetpub\wwwroot\ModelGlue?\unity\framework\ModelGlue?.cfc (359) D:\Inetpub\wwwroot\ModelGlue?\unity\framework\ModelGlue?.cfc (332) D:\Inetpub\wwwroot\ModelGlue?\unity\framework\ModelGlue?.cfc (306) D:\Inetpub\wwwroot\ModelGlue?\unity\framework\ModelGlue?.cfc (264) D:\Inetpub\wwwroot\ModelGlue?\unity\ModelGlue?.cfm (104) D:\Inetpub\wwwroot\YourApp?\index.cfm (50)

Change History

  Changed 19 years ago by denny

By replacing the loop around line# 151 with this one:

                <cfloop from="1" to="#arrayLen(metadata.primaryKeys)#" index="i">
                        <cfloop from="1" to="#arrayLen(metadata.xml.object.properties)#" index="objPropCol">
                          <cfif metadata.xml.object.properties.property[objPropCol].name.XmlText
                                                eq metadata.primaryKeys[i]>
                                <cfset priKeyAlias = metadata.xml.object.properties.property[objPropCol].alias.XmlText>
                                </cfif>
                        </cfloop>                       
                        <cfinvoke component="#record#" method="get#priKeyAlias#" returnvariable="tmp" />
                        <cfset arguments.event.setValue(priKeyAlias, tmp) />
                </cfloop>

you can get it to work, but I don't know if this is the best code to fix the problem.

in reply to: ↑ description   Changed 19 years ago by denny

Replying to Bryan S:

This is a simplified version of Ticket #226 (closed defect: worksforme) which is

It appears the fix is pretty simple, from limited testing.

Change this line: <cfif fields[i].primaryKey>

<cfset arrayAppend(result.primaryKeys, fields[i].name) />

</cfif>

To this: <cfif fields[i].primaryKey>

<cfset arrayAppend(result.primaryKeys, fields[i].alias) />

</cfif>

In unity/orm/ReactorAdaptor.cfc

Hope that's it!

  Changed 19 years ago by joe.rinehart

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

I'll be consolidating alias issues into master tickets to be resolved after the 2.0 release.

  Changed 19 years ago by denny

Alas, the one line fix never made it in.

Note: See TracTickets for help on using tickets.