Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Gary S. / ()
Created: 07/23/2019
Components: Language
Versions: 2018
Failure Type: Incorrect w/Workaround
Found In Build/Fixed In Build: Update 4 /
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Win All
Vote Count: 0
Problem Description:
Within a function, the Arguments scope is a struct, also accessible via `Local.Arguments`.
This struct is not treated as such by the query functions of CFML. Specifically, when attempting to add a row to a newly created query object using the arguments struct, an error is returned indicating that only a struct or array of structs may be used to add rows.
This applies when using Local.Arguments, or copying the Arguments struct using `StructCopy`.
Furthermore, if adding the arguments struct to an array and passing this to the `QueryAddRow()` function, the resulting query contains the entire arguments struct in the second field of the first row.
All the above works as expected in Lucee.
Steps to Reproduce:
Fiddle here: https://cffiddle.org/app/file?filepath=92e9527d-8913-4a90-b12a-eb5b266dea0a/99cce3f2-74c0-4a8e-a8de-e93b9839ad97/6839c9d0-3c60-4fbe-8be0-f5f618b3180c.cfm
Code:
```
<cfscript>
public function createQueryFromArguments(
required string test1
, required string test2
) {
// Create CSV
Local.testQuery = queryNew(structKeyList(Arguments));
queryAddRow(Local.testQuery, Arguments);
return Local.testQuery
}
writeDump(createQueryFromArguments('foo', 'bar'));
</cfscript>
```
Actual Result:
Unhandled Exception: Only struct or array of struct is allowed for adding a row.
Expected Result:
Query row populated with content of arguments struct, or at least, `Local.Arguments`.
Any Workarounds:
Easy enough to construct a temporary struct containing the arguments with the following code:
```
for (Local.thisArgument in StructKeyList(Arguments)) {
Local.rowStruct[Local.thisArgument] = Arguments[Local.thisArgument];
}
queryAddRow(Local.testQuery, Local.rowStruct);
```
However, I still think this should be considered a bug, as it does not function as expected, and works fine in Lucee.
Attachments:
Comments: