tracker issue : CF-3818587

select a category, or use search below
(searches all categories and all time range)
Title:

Incorrect cast when iterating over an array of elements containing values from a query object.

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): JF Robichaud / JF Robichaud (jfrobishow)

Created: 09/04/2014

Components: Database, Query-of-Query(IMQ)

Versions: 11.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF11_Final / CF11 Update5

Priority/Frequency: Normal / Some users will encounter

Locale/System: ALL / Windows 7 64-bit

Vote Count: 2

Listed in the version 11.0.05.293506 Issues Fixed doc
Problem Description:

When populating the value of an array by iterating over a query object containing Int/BigInt ArrayFind doesn't produce the expected result when used within a for loop. 

Direct access works. If you trim the iterator value you also get the expected result. Changing the query column type to something other than an array also work.

Steps to Reproduce:

<cfscript>
    /*
    Valid column type.  Integer and BigInt do not produce the expected result.
    Integer | BigInt | Double | Decimal | VarChar | Binary | Bit | Time | Date | Timestamp | Object
    */
  	rs = queryNew("column1", "Integer");
    queryAddRow(rs, 2);

    querySetCell(rs, "column1", 1, 1);
    querySetCell(rs, "column1", 1, 1);

    querySetCell(rs, "column1", 2, 2);
    querySetCell(rs, "column1", 2, 2);
</cfscript>

<cfset x = arraynew(1)>
<cfloop query="rs">
  <cfset x[arrayLen(x)+1] = rs["column1"][rs.CurrentRow]>
</cfloop>

<cfscript>
  writeDump(x);

  for(i=1; i <= rs.RecordCount; i++){
    writeDump(arrayFind(x, i)); //Expected result - find the value... it doesn't on CF but works correctly on Railo.
    writeOutput("<br>");
  }
</cfscript>

Actual Result: Expecting ArrayFind to find the value.  It doesn't.

Expected Result: Expecting ArrayFind to find the value.  It doesn't.

Any Workarounds: 
  Changing the column type to something other than integer.
  or Triming the iterator before passing it to arrayFind
  or Trimming the value before storing it in the array.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3818587

External Customer Info:
External Company:  
External Customer Name: jfrobishow
External Customer Email:  
External Test Config: My Hardware and Environment details: Fails on CFLive.net and works on Railo.

Attachments:

Comments:

Interesting. if one does this instead; arrayFind(x, i&"") then it "works" (I'm not advocating that as a work around, just an observation) -- Adam
Comment by External U.
11092 | September 04, 2014 10:35:16 AM GMT
+1.0 //////////////////////
Vote by External U.
11096 | September 04, 2014 10:35:28 AM GMT
+1 ......................
Vote by External U.
11097 | November 24, 2014 02:13:09 AM GMT
This issue is fixed and fix will be available with the upcoming update of ColdFusion 11.
Comment by Nimit S.
11093 | January 19, 2015 09:49:15 AM GMT
The fix for this bug is available in the pre-release build of ColdFusion 11 Update 5
Comment by CFwatson U.
11094 | February 20, 2015 09:24:08 AM GMT
Verified this is fixed in CF11 Update 5 (build 11,0,05,293506). Thanks!, -Aaron
Comment by External U.
11095 | September 04, 2015 09:14:53 PM GMT