Status/Resolution/Reason: To Fix//Investigate
Reporter/Name(from Bugbase): Aaron N. / ()
Created: 08/28/2019
Components: Language, Functions
Versions: 2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2018.0.04.314546 /
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Platforms All
Vote Count: 0
Issue: Inconsistencies in Array Case/NoCase Functions
Note: Instead of fixing the issues in this ticket, the language would be more useful if CF-4205066 was implemented which would make this ticket irrelevant.
Repro:
Just run this repro and see the Actual vs Expected below.
<cfscript>
function displayBIFResult(required array haystack, required any needle) {
for(var arrayFunction in ["arrayFind","arrayFindNoCase","arrayFindAll","arrayFindAllNoCase","arrayContains","arrayContainsNoCase","arrayDelete","arrayDeleteNoCase"]) {
try {
var result = evaluate(arrayFunction & '(duplicate(ARGUMENTS.haystack), ARGUMENTS.needle)');
}
catch(any e) {
var result = e.message;
}
writeOutput(arrayFunction & '(): ' & serializeJSON(result, false, false) & '<br>');
}
}
function displayMFResult(required array haystack, required any needle) {
for(var arrayFunction in ["find","findNoCase","findAll","findAllNoCase","contains","containsNoCase","delete","deleteNoCase"]) {
try {
var result = evaluate('duplicate(ARGUMENTS.haystack).' & arrayFunction & '(ARGUMENTS.needle)');
}
catch(any e) {
var result = e.message;
}
writeOutput(arrayFunction & '(): ' & serializeJSON(result, false, false) & '<br>');
}
}
writeOutput("<h1>BIFs w/ complex needle</h1>");
displayBIFResult([["MyString"]], ["MyString"]);
writeOutput("<hr>");
displayBIFResult([["MyString"]], ["MYSTRING"]);
writeOutput("<hr>");
displayBIFResult([], [true]);
writeOutput("<h1>Member Functions w/ complex needle</h1>");
displayMFResult([["MyString"]], ["MyString"]);
writeOutput("<hr>");
displayMFResult([["MyString"]], ["MYSTRING"]);
writeOutput("<hr>");
displayMFResult([], [true]);
writeOutput("<h1>BIFs w/ boolean</h1>");
displayBIFResult([true], true);
writeOutput("<hr>");
displayBIFResult([], true);
writeOutput("<h1>Member Functions w/ boolean</h1>");
displayMFResult([true], true);
writeOutput("<hr>");
displayMFResult([], true);
writeOutput("<h1>BIFs w/ number</h1>");
displayBIFResult([1], 1);
writeOutput("<hr>");
displayBIFResult([], 1);
writeOutput("<h1>Member Functions w/ number</h1>");
displayMFResult([1], 1);
writeOutput("<hr>");
displayMFResult([], 1);
writeOutput("<h1>BIFs w/ date</h1>");
displayBIFResult([createDate(2020,1,1)], createDate(2020,1,1));
writeOutput("<hr>");
displayBIFResult([], createDate(2020,1,1));
writeOutput("<h1>Member Functions w/ date</h1>");
displayMFResult([createDate(2020,1,1)], createDate(2020,1,1));
writeOutput("<hr>");
displayMFResult([], createDate(2020,1,1));
</cfscript>
Actual Result:
1) When searching for a non-simple value, a different error message is returned for FindNoCase vs ContainsNoCase/DeleteNoCase. The former returns "Valid datatype for element to search is String." while the latter return "Valid datatypes in array are String|Boolean|Number.".
2) When searching for a non-simple value, in an empty array, ContainsNoCase/DeleteNoCase return false instead of error message.
3) Array's NoCase functions allow searching for String|Boolean|Numeric but not Date.
Expected Result:
1) Array's NoCase functions should throw the same error message when searching for a non-simple value.
2) Array's NoCase functions should throw an exception message, instead of returning false, when searching for a non-simple value.
3) Array's NoCase functions should allow searching for Date b/c Date is a simple value per isSimpleValue(now())==YES and https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/elements-of-cfml/data-types.html
Attachments:
Comments: