This has been discussed before, but I’ve never been pleased with the answer so I’d like it to be discussed again. Please provide any public feedback before the TAG addresses it.
This is an Adobe ColdFusion incompatibility, but I’m entering this as an enhancement because it’s been discussed several times before and previously was stated that it was on purpose so I’d like to address the previous decision which the TAG can help do.
Adobe CF allows array functions to be against query columns like so:
myQry = queryNew( 'amount' ); myQry.addRow(); myQry.setCell( 'amount', 5, 1 ); myQry.addRow(); myQry.setCell( 'amount', 15, 2 ); writeOutput( arraySum( myQry[ 'amount' ] ) );
Adobe CF returns “20”, but Lucee throws the exception, "Can’t cast Object type Number to a value of type Array ".
Lucee provides a separate function called QueryColumnData() to get the data in a query column back as an array. I’d like to discuss providing compatibility with Adobe Cf for the following reasons:
- I think their syntax is succinct and makes sense
- This has been a stumbling block I’ve seen mentioned in just about every blog article I’ve ever read about converting to Railo/Lucee.
- I regularly hear people complaining about running into this and not understanding why their code doesn’t run. (just this week on Twitter)
- This has been a pain for every single Adobe CF app I have ever converted to Lucee myself
- I’m having to waste time right now, again, on this issue in an app I’m converting and i really just wish it worked.
I get that Lucee has a function for this and I think that’s great, but I want to see Lucee also allow for the shortcut syntax of address query columns as arrays for the pure sake of helping people convert their ACF code over to Lucee.
Ooh, and I’ll try out one of these poll doohickey’s @modius showed us
Should query columns be treated as an array like Adobe CF?
- Yes, this is useful
- No, that is not useful
- I don’t care, when is Lucee 5 coming out??
- What is Adobe ColdFusion?