tracker issue : CF-4197153

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

Arraydelete throws error when passed a struct to search for

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Alex Skinner / Alex Skinner (Alex Skinner)

Created: 10/30/2016

Components: Language, Functions

Versions: 2016

Failure Type:

Found In Build/Fixed In Build: CF2016_Update3 /

Priority/Frequency: Major / Some users will encounter

Locale/System: ALL / Mac 10 All

Vote Count: 1

As part of an effort to port an existing application to also work on Adobe ColdFusion we are having problems with the following code.

According to the documentation you should be able to search for structs

<cfscript>
fields = [{"name":"title"},{"name":"main_image"},{"name":"layout"},{"name":"teaser"},{"name":"main_content"},{"name":"sidebar_content"},{"name":"active"}];

writedump(fields); // should have 7 items

for ( field in fields ) {
	if (field.name == "layout") {
		arraydelete(fields, field);
	}
}

writedump(fields); // should now have 6 items
</cfscript>

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

Watson Bug ID:	4197153

External Customer Info:
External Company:  
External Customer Name: Alex Skinner
External Customer Email:  
External Test Config: N/A

Attachments:

Comments:

This effects older versions of CF too
Comment by External U.
1567 | October 30, 2016 05:45:11 AM GMT
+1 - This should work.
Vote by External U.
1570 | October 30, 2016 03:55:59 PM GMT
Hi Alex, I agree this should work, and have voted. Meantime, perhaps this would work? <cfscript> fields = [{"name":"title"},{"name":"main_image"},{"name":"layout"},{"name":"teaser"},{"name":"main_content"},{"name":"sidebar_content"},{"name":"active"}]; fieldsTempWorkaround = fields.duplicate();//temporary workaround for CF-4197153 writedump(fields); // should have 7 items for ( field in fieldsTempWorkaround ) { if (field.name == "layout") { arraydelete(fields, field); } } writedump(fields); // should now have 6 items </cfscript> Thanks!, -Aaron
Comment by External U.
1568 | October 30, 2016 03:59:10 PM GMT
Following Code would work: <cfscript> fields = [ {"name":"title"} , {"name":"main_image"} , {"name":"layout"} , {"name":"teaser"} , {"name":"main_content"} , {"name":"sidebar_content"} , {"name":"active"} ]; writedump(fields); // should have 7 items arraydelete(fields, {"name":"layout"}); writedump(fields); // should now have 6 items </cfscript> ArrayDelete is working fine. But deleting elements while looping through it would throw ConcurrentModificationException. Hence not a bug and closing it .
Comment by Suchika S.
1569 | March 16, 2017 07:04:29 AM GMT