tracker issue : CF-4123732

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

For-in Doesn't Loop Over Cached Query

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Brian Love / Brian Love (Brian Love)

Created: 03/01/2016

Components: Language

Versions: 2016

Failure Type:

Found In Build/Fixed In Build: CF2016_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Mac 10.11

Vote Count: 3

Listed in the version 2016.0.02.299200 Issues Fixed doc
Problem Description: The for-in construct for looping over a query that is cached doesn't work.

Steps to Reproduce: Using <cfquery> or QueryExecute() with the cacheregion and cacheid options returns a cached query object. Looping over this query result using <cfloop> works as expected. However, looping over the query using the script style for-in syntax does not work.

Please see gist:
Or via

Actual Result: The for-in should loop over the query rows. It does not.

Expected Result: The for-in should loop over the query rows.

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

Watson Bug ID:	4123732

External Customer Info:
External Company:  
External Customer Name: Brian Love
External Customer Email:  
External Test Config: My Hardware and Environment details: Mac OS X 10.11 with version 2016.0.0.298074.



[subscribe] I presume this is down to poor testing of that cached query optimisation CF2016 added
Comment by External U.
4415 | March 01, 2016 08:03:17 PM GMT
Issue exists with CF 2016 only. Works as expected on CF 11. Copying the test below, <cfscript> //create dummy query q = QueryNew("id,foo"); QueryAddRow(q); QuerySetCell(q, "id", "1"); QuerySetCell(q, "foo", "bar"); //cache it CacheRegionNew("queries", {}, false); results = QueryExecute("select * from q", {}, {dbtype="query", cacheregion="queries", cacheid="cacheid"}); //nothing outputs here?!?! for (row in results) { writeoutput(; writeoutput(": "); writeoutput(; } //let's dump it writeDump(results); </cfscript> <cfoutput> <cfloop query="results"> </cfloop> </cfoutput>
Comment by Immanuel N.
4416 | March 16, 2016 12:16:54 AM GMT
+1 - Adobe this is very bad. This needs pushed-out in an update ASAP!
Vote by External U.
4422 | April 28, 2016 03:26:17 PM GMT
Hi Immanuel, I've also reproduced w/ this: <cfscript> q = queryNew("foobar", "", [["foo"],["bar"]]); q2 = queryExecute("SELECT * FROM q", [], {dbtype="query", cachedWithin=createTimeSpan(0,0,0,30)}); writeDump(q2); for(row in q2) { abort; } writeDump(q2); q3 = queryExecute("SELECT * FROM art WHERE artID <= 2", [], {datasource="cfartgallery", cachedWithin=createTimeSpan(0,0,0,30)}); writeDump(q3); for(row in q3) { abort; } writeDump(q3); </cfscript> Actual result: 4 dumps Expected result: The abort should abort. So it doesn't matter if query was manually-created or fetched from db. And cachedWithin is enough to trigger this, when using Ehcache. This is serious b/c no exception is being thrown. Code running on CF2016 could assume the loop processed successfully. I hope this can be pushed-out in an update very soon. Thanks!, -Aaron
Comment by External U.
4417 | April 28, 2016 03:31:13 PM GMT
Just noting that the issue does not affect queryEach(): q4 = queryNew("foobar", "", [["foo"],["bar"]]); q5 = queryExecute("SELECT * FROM q4", [], {dbtype="query", cachedWithin=createTimeSpan(0,0,0,30)}); q5.each(function() { writeDump(ARGUMENTS); abort; }); Actual and expected result: arguments are dumped and then request aborted (good) Thanks!, -Aaron
Comment by External U.
4418 | April 28, 2016 03:41:51 PM GMT
Thanks for the heads-up, Aaron! I can confirm this fix will be available with the next update.
Comment by Immanuel N.
4419 | May 02, 2016 04:18:30 AM GMT
test note
Comment by CFwatson U.
4420 | June 07, 2016 04:18:59 AM GMT
The fix for this bug is available as part of the early-access build for ColdFusion 2016 Update 2.
Comment by CFwatson U.
4421 | June 07, 2016 04:25:37 AM GMT