I did not see if this has been corrected or not. I’m running about a month old version of reactor.  Is this bug in the trac?

There is a bug in returnObjectField when 2 tables in a join are named the same.

 

I have 2 tables that are joined like so

 

<object name="TableA">

<hasOne name="TableB">

            <relate from="TableBId" to="TableBId" />

      </hasOne>

</object>

 

<object name="TableB">

      <hasMany name="TableA">

            <relate from="TableBId" to="TableBId" />

      </hasMany>

</object>

 

Table A and Table B both contain a column named [DuplicateColumnName] that is not a foreign or primary key.

 

If you write an object query to get just the [DuplicateColumnName] from table B It will create a select statement to return both [TableA].[DuplicateColumnName] and [TableB].[DuplicateColumnName]  which coldfusion can not decide which column to throw in a query object and you have a 50 / 50 chance of getting the wrong data back.

 

The oo query should only be returning [TableB].[DuplicateColumnName]

 

Coldfusion code oo query

var qry = CreateQuery();

                                                // join on the TableB table

              qry.innerJoin("TableA", "TableB", "TableB");

                                    // limit results

            qry.getWhere().isEqual("TableA","TableAID",Arguments.ID);

            qry.getWhere().isEqual("TableB","IsActive",1);

                                                // get only the relevant fields

            qry.returnObjectField("TableA", "AColumn");

            qry.returnObjectField("TableA", "AnotherColumn");

            qry.returnObjectField("TableB","Description");

                                    // order by

            qry.getOrder().setAsc("TableA","FirstName");

 

 

SQL actually sent

 

SELECT           

[TableA].[AnotherColumn] AS [AColumn],

[TableA].[AnotherColumn] AS [AnotherColumn],

 [TableA].[DuplicateColumnName] AS [DuplicateColumnName],

                        [TableB].[DuplicateColumnName] AS [DuplicateColumnName]

 

FROM              

[TableA] AS [TableA]

                        INNER JOIN [TableB] AS [TableB] ON [TableB].[TableBID] = [TableA].[TableAID]

 

WHERE           

[TableA].[TableAID] = 21212

AND                 [TableB].[IsActive] = 1

 

ORDER BY      

[TableA].[FirstName]

 

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alan Dix
Sent: Thursday, July 13, 2006 2:55 PM
To: [email protected]
Subject: [Reactor for CF] newbie error

 

We are just getting started with Reactor, using the documented examples.

 

Stuck on this error:

Invalid data for CFSQLTYPE CF_SQL_INTEGER.

  The error occurred in C:\Inetpub\wwwroot\reactor\base\abstractGateway.cfc: line 288
Called from C:\Inetpub\wwwroot\reactor\project\Example\Gateway\AddressGateway.cfc: line 85
Called from C:\Inetpub\wwwroot\reactor\project\Example\Dao\AddressDao.cfc: line 132
Called from C:\Inetpub\wwwroot\reactor\project\Example\Record\AddressRecord.cfc: line 200
Called from C:\Inetpub\wwwroot\reactor\project\Example\Record\CustomerRecord.cfc: line 270
Called from C:\Inetpub\wwwroot\exampleReactorCode\recordObjectPage.cfm: line 6

286 :                                 
287 :                          </cfloop>
288 :                  </cfif>
289 :                  
290 :                  <!---<cfif getObjectMetadata().getName() IS "Contact">

 

 

<cfset Reactor = CreateObject("Component", "reactor.reactorFactory").init(expandPath("reactor.xml")) />

 

<!--- create a user Record --->

<cfset CustomerRecord = Reactor.createRecord("Customer") />

it fails on the line above.

 

Alan

 

****************************************************************************

This email may contain confidential
material. If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.

 ***************************************************************************

 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to