Title:
QueryFilter does not remove rows as expected when consecutive target rows exist
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Dave Jones / Dave Jones ()
Created: 03/21/2017
Components: Language, Functions
Versions: 2016
Failure Type: Others
Found In Build/Fixed In Build: 2016,0,03,300466 / 2016.0.04.302324
Priority/Frequency: Normal /
Locale/System: / Win 2012 Server x64
Vote Count: 6
Problem Description:
Using queryFilter() on a query having consecutive rows that should be removed based on the filter function logic results in an incorrectly filtered result. It appears that the filter action is failing to remove every other row in the set of consecutive rows.
Steps to Reproduce:
Here is a simple snippet that displays the behavior. Here, a query of names/ages is being filtered to exclude those having an age of 21. Notice that only every other row with age = 21 is removed.
<cfscript>
myQuery = queryNew("name,age,rn", "varchar,integer,integer", [
{name: "Billy", age: 20, rn:1}
, {name: "Jane", age: 22, rn:2}
, {name: "Tommy", age: 23, rn:3}
, {name: "Sam", age: 21, rn:4}
, {name: "Sally", age: 21, rn:5}
, {name: "Jane", age: 21, rn:6}
, {name: "Jack", age: 21, rn:7}
, {name: "Beth", age: 21, rn:8}
, {name: "Barney", age: 21, rn:9}
, {name: "Archie", age: 25, rn:10}
]);
writedump(myQuery);
x = queryFilter(myQuery, function (Obj, index) {
writedump({obj:obj, index:index});
return obj.age != 21;
});
writeDump(x);
</cfscript>
Actual Result:
The filtered query contains some rows that should be removed based on the filter function.
Expected Result:
All rows meeting the filter function criteria should be removed.
Any Workarounds:
Use query of queries.
Attachments:
Comments: