Fun CFML quiz. Read this code and decide what you...
# lucee
b
Fun CFML quiz. Read this code and decide what you think it does. Then run it and see if you were right šŸ™‚ Note: Adobe CF behaves differently. https://trycf.com/gist/86d6f4c1fe54baa964055d0ac61042ec/lucee5?theme=monokai Answer in the thread.
These aren't all documented, but Lucee will accept in
queryAddRow()
and the third param of
queryNew()
ā€¢ An array of simple 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)
That last bullet I never knew until I was reading the Java code today in Lucee.
And there's two interesting things about it ā€¢ each struct value can have a different length array and there won't be an error. Extra rows will just have an empty string if the array for that row didn't have enough items ā€¢ It's also impossible to set an actual array into a cell value when using this approach as Lucee assumes your array is meant to be translated into separate rows.
d
I certainly would expect what ACF is doing, especially since the column has an
object
datatype.
šŸ‘ 1
a
^^^ what @dswitzer says. I'd also expect me to raise a point with @Mark Takata (Adobe) to get the examples sorted out to be clearer and more to the point on both of them, especially
queryAddRow
. And
queryAddRow
needs its parameters table updated to reflect reality. Lucee's behaviour with
queryAddRow
seems like a bug. A struct should only add one row to the query (ie: CF has it right, Lucee has it wrong).
šŸ‘ 1
Bravo to cfdocs for having clear, concise and complete examples for
queryAddRow
šŸ˜Ž 1
s
Weird that ACF 10, 11 and 2016 all error out on the first line of code: "Invalid construct. on line 2"...
b
@Sebastiaan Naafs - van Dijk Add semicolons if you want to run it on older versions of CF šŸ™‚
šŸ‘šŸ¼ 1
The code works all the way back to CF11 with semis
s
Yes, addRow doesn't exist in ACF10