Saturday, 29 September 2012

valueList(): bouquet for OpenBD... play catch-up, ColdFusion & Railo

G'day:
One of the most curious things about CFML is the valueList() function.  As far as I know, it is the only function in all of CFML for which the argument must be of datatype "Query Column" (please let me know if there are any other examples?).   The Query Column (coldfusion.sql.QueryColumn in CF,  com.naryx.tagfusion.cfm.engine.cfQueryColumnData in OpenBD, and I can't coerce Railo into considering query["column"] a column like I can in CF and OpenBD, so I can't tell you what Railo the Railo class is... Railo just says it's a string), is - unfortunately - not a very well-realised data type in CFML.


Oh, the code I used to get the class of the column in CF and OpenBD was this:

cv = createObject("java", "ClassViewer");
q = queryNew("col");

writeOutput("<pre>#cv.viewObject(q["col"])#</pre>");

Where ClassViewer.class is the thing I mentioned in that other article a while back.  I keep forgetting I've got a CF version of it now, and persist with the Java version. Oops.

Now where OpenBD comes good here is in this code:

function colours(){
    var colours = queryNew("");
    queryAddColumn(colours, "maori", "varchar", ["whero", "ma", "mangu"]);
    queryAddColumn(colours, "english", "varchar", ["red","white","black"]);
    return colours;
}
maoriColours = valueList(colours().maori);
writeOutput(colours().maori);

This works in OpenBD.  Cool.

The thing is... there's no good reason why this shouldn't work in CF and Railo too.  valueList() should just take an expression that evaluates to a query column, and that's the end of it.  The CF docs for valueList() are a bit enigmatic:

Parameter Description
query.column Name of an executed query and column. Separate query name and column name with a period.

WTH?  What the hell does it matter what the specific syntax is?  As long as the value is a query column, that should be all that's necessary.  I hate to think that the code parser has to have a specific exception in there to make sure that specific syntax is adhered to, rather than just assuming at runtime the value will be a query column.

Anyway, I'm gonna raise a ticket for both ColdFusion (3339105) and Railo (RAILO-2078) to play a bit of catch-up here, and will start a thread on the Railo forums to see what their bods have to say about it (there's no point doing the same thing on the Adobe CF forums because the Adobe dudes don't pay attention to it).

That's it... short and sweet.

Thoughts?

--
Adam