tracker issue : CF-3316784

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

arrayFindAllNoCase() returns false negatives

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 08/23/2012

Components: Language, Closures

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Win All

Vote Count: 1

Description
Problem Description:
arrayContains() is supposed to be case sensitive, but when looking-up a struct, the look-up is case insensitive

Steps to Reproduce:
<h1>Control</h1>
<p>This demonstrates that the function works with same-case</p>
<cfset arrayToSearch = [["value"]]>
<cfset arrayToFind = ["value"]>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#arrayToFind#" label="arrayToFind">

Was it found:
<cfdump var="#arrayFindAllNoCase(arrayToSearch, arrayToFind)#">
<br />

<cfset arrayToSearch = [new Object("value")]>
<cfset objectToFind = new Object("value")>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#objectToFind#" label="objectToFind">

Was it found:
<cfdump var="#arrayFindAllNoCase(arrayToSearch, objectToFind)#">
<br />
<hr />

<h1>Test</h1>
<p>This demonstrates that the function fails on different casing</p>
<cfset arrayToSearch = [["value"]]>
<cfset arrayToFind = ["VALUE"]>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#arrayToFind#" label="arrayToFind">

Was it found:
<cfdump var="#arrayFindAllNoCase(arrayToSearch, arrayToFind)#">
<br />

<cfset arrayToSearch = [new Object("value")]>
<cfset objectToFind = new Object("VALUE")>

<cfdump var="#arrayToSearch#" label="arrayToSearch">
<cfdump var="#objectToFind#" label="objectToFind">

Was it found:
<cfdump var="#arrayFindAllNoCase(arrayToSearch, ObjectToFind)#">
<br />


Actual Result:
The mismatched-case versions are not found

Expected Result:
The mismatched-case versions should be found

Any Workarounds:
Doesn't matter: it should work properly.

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

Watson Bug ID:	3316784

External Customer Info:
External Company:  
External Customer Name: Adam Cameron.
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Sorry, here's Object.cfc (it's used in the test code above. component { public Object function init(value){ variables.value = arguments.value; this.value = variables.value; return this; } }
Comment by External U.
18388 | August 23, 2012 03:59:06 PM GMT
This was reported 9 months ago and hasn't been verified yet. What's it going to take to have it reviewed? I used the sample ColdFusion10 code here: http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WS2EF4F7C2-F41D-42fe-940D-B7C0212FF3D9.html and generated this sample that highlights the error: http://pastebin.com/yRtwDuRa Please review on your installation of ColdFusion 10 and determine what your results are. (I'm using CF10 Developer 10,0,9,284568 with Java 1.7.0_15 on Windows Server 2008 R2.)
Comment by External U.
18389 | June 05, 2013 10:53:32 AM GMT
It doesn't work as documented. (String searches are case-sensitive.) How can I use it if it doesn't work reliably & as documented.
Vote by External U.
18392 | June 05, 2013 10:57:05 AM GMT
This is not a bug. The case only matters for a string and this function does find all the matching elements of array ignoring the case. ArrayFindAllNoCase will look at the case of String elements in the array but not inside the object elements. This means that ArrayFindAllNoCase(["adam", "Adam", "ada", "ADAm"], "Adam") will return array with 3 indices (1,2,4) matching the case.
Comment by Rupesh K.
18390 | June 07, 2013 06:54:16 AM GMT
If Rupesh's comment is the intended use for this function then the documentation is wrong. https://learn.adobe.com/wiki/display/coldfusionen/ArrayFindAllNoCase It says nothing about passing a string as the second parameter, and only defines how it would work with a callback.
Comment by External U.
18391 | October 16, 2013 11:17:03 PM GMT