Duplicate
Details
Assignee
Michael OffnerMichael OffnerReporter
Brad WoodBrad WoodLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
NonePriority
New
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Brad Wood
Brad WoodLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Priority
Created 29 March 2022 at 02:00
Updated 9 June 2023 at 16:44
Resolved 9 June 2023 at 16:44
QueryAddRow()
, and the third param toqueryNew()
will accept the followingAn array of values (placed positionally in the new single row)
A struct of values (placed via key name matching column name in a single row)
An array of structs (One new query row per array item, each struct added like bullet #2
A struct of arrays (placed via key name matching column name, one row per array value)
The last bullet is a source of issue (and doesn’t seem to be documented anywhere) as it has a different behavior than Adobe CF and cannot be used to set an actual array into a single column cell, which is valid and supported by functions such as
querySetCell()
.The following code shows the difference of behaviors between Adobe and Lucee
https://trycf.com/gist/86d6f4c1fe54baa964055d0ac61042ec/lucee5?theme=monokai
qry = queryNew( "name,items","varchar,object" ) qry.addRow( 1 ) qry.setCell( 'name', 'Brad' ) qry.setCell( 'items', [ 1, 2, 3 ] ) qry.addRow( { 'name' : 'Luis', 'items' : [ 4, 5, 6 ] } ); writedump( qry )
Adobe only has two rows in the query when it’s done, but Lucee has 4 rows in the query as it breaks out Luis' “items” into separate rows.
Since Lucee’s docs don’t actually document this last behavior, I’m tempted to say perhaps it should be removed, or AT LEAST not attempted if not all the struct values contain arrays of the same length. But if there are for sure people using the behavior, then at least this ticket can serve as documentation of the difference.