Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at NCDevCon 2016 (Raleigh, NC) with: Matthew Eash
Ben Nadel at NCDevCon 2016 (Raleigh, NC) with: Matthew Eash@mujimu )

Calling Array Functions on ColdFusion Query Columns Part II

By Ben Nadel on
Tags: ColdFusion

The other day I had mentioned that someone posted a great tip about running ColdFusion array functions on query columns. After some testing I had come across the fact that column notation made a huge difference. For example,

  • <cfset flSum = ArraySum( qGirls[ "weight" ] ) />

... works, but the following,

  • <cfset flSum = ArraySum( qGirls.weight ) />

... throws an error. To investigate, I tried dumping out the Java classes that were representing these objects underneath:

  • <!--- Dump out java class name. --->
  • <cfdump var="#qGirls.weight.GetClass().ToString()#" />
  • <!--- Dump out java class name. --->
  • <cfdump var="#qGirls[ 'weight' ].GetClass().ToString()#" />

It turns out that both of these ColdFusion objects are the java class "coldfusion.sql.QueryColumn". This means that on the Java side of the universe they are the same object. I don't understand exactly how ColdFusion is built on top of Java, but I guess the problem here lies in ColdFusion, before anything gets cast to Java? No idea.

Reader Comments