tracker issue : CF-3316760

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

arrayContains() returns false positives

| 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

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: 0

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

Steps to Reproduce:
<cfset arrayToSearch = [{key="value"}]>
<cfset structToFind = {key="VALUE"}>

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

<cfoutput>
Was it found: #arrayContains(arrayToSearch, structToFind)#<br />
</cfoutput>

Actual Result:
Was it found: YES

Expected Result:
Was it found: NO

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

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

Watson Bug ID:	3316760

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

Attachments:

Comments:

String search in arrayContains is case sensitive, but in this case the element to search is a struct object. In case of a struct object comparison would pass or return true. Try this: <cfset str1 = {key="VALUE"}> <cfset str2 = {key="Value"}> <cfif objectEquals(str1,str2)> Equals. </cfif> Here the condition - objectEquals(str1,str2) would return true. (Comment added from ex-user id:sagarg)
Comment by Adobe D.
18405 | September 04, 2012 11:43:14 PM GMT
That's a daft rationalisation, Sagar, because objectEquals() makes no claim to be case-sensitive, whereas arrayContains() DOES. If a function claims to be case-sensitive, then it needs to be case-sensitive. Not "kinda case-sensitive sometimes" that's just slack.
Comment by External U.
18406 | October 18, 2012 02:27:03 AM GMT