Heads-up: E/R raised for valueList()

79 views
Skip to first unread message

Adam Cameron

unread,
Sep 29, 2012, 3:57:15 PM9/29/12
to ra...@googlegroups.com
G'day
I've just raised this enhancement request for Railo: https://issues.jboss.org/browse/RAILO-2078

Basically OpenBD allows the argument value for valueList() to be any expression which evaluates to a query column, which is how valueList() ought to work, but never has in ColdFusion, and doesn't in Railo. 

I discuss it further in my blog, here: http://adamcameroncoldfusion.blogspot.co.uk/2012/09/valuelist-bouquet-for-openbd-play-catch.html

This is just an FYI, really.

Cheers.

--
Adam

Todd

unread,
Sep 30, 2012, 10:08:42 AM9/30/12
to ra...@googlegroups.com
Just an FYI, Railo has a way, just not your way:

Adam Cameron

unread,
Sep 30, 2012, 2:50:10 PM9/30/12
to ra...@googlegroups.com
Sorry Todd: was that the right link?  I see no reference to valueList() on that page?

--
Adam

Todd

unread,
Sep 30, 2012, 5:01:25 PM9/30/12
to ra...@googlegroups.com
Right, because it's not needed to populate a query.

Adam Cameron

unread,
Sep 30, 2012, 5:29:53 PM9/30/12
to ra...@googlegroups.com
I am beginning to suspect you didn't read either the ticket or the explanatory blog post.

--
Adam

Todd

unread,
Sep 30, 2012, 8:07:33 PM9/30/12
to ra...@googlegroups.com
Nope, I got caught up on the query creation which is easier in Railo.

I see the line you're pointing out on the ticket:

maoriColours = valueList(colours().maori); // <=== this is the bit to look at here!!

Adam Cameron

unread,
Oct 1, 2012, 3:14:35 AM10/1/12
to ra...@googlegroups.com
No probs.  And, yes, I re-emphasised the relevant line of code during our discussion here as I thought it might not have been as clear as it ought to have been.

The query-creation code in the example is more verbose than it would need to be on Railo or CF, yeah: OpenBD doesn't support that improved syntax yet, and it was example OpenBD code.

So, anyway... valueList() then.  Thoughts?

--
Adam

Michael Offner

unread,
Oct 1, 2012, 4:30:04 AM10/1/12
to ra...@googlegroups.com
i peronally are not a big fan of the function valueList/valueArray for one reason.
when you output
#myQuery.myColumn#
you get a single cell, but with exact the same expression as parameter to valueList
valueList(myQuery.myColumn)
 you get a reference to a column?!
in railo you can also write
valueList("myQuery.myColumn") what is already better, but still ugly.
i would prefer to have something like this:
queryGetColumn(query query, string columnName)

/micha







2012/10/1 Adam Cameron <adamcamero...@gmail.com>



--
/micha

Michael Offner CTO Railo Technologies GmbH

Mark Drew

unread,
Oct 1, 2012, 4:35:17 AM10/1/12
to ra...@googlegroups.com
I agree.  GetQuery().col is a reference to a value, not a definition of a column. But you are right in one way, how do you reference a column?

I would go with getQuery().getColumn()
Or as Micha had mentioned QueryGetColumn(q,c, quoted=true/false)

Regards
Mark Drew

Adam Cameron

unread,
Oct 1, 2012, 4:35:53 AM10/1/12
to ra...@googlegroups.com
Well that behaviour is not that surprising, Micha: it would be completely legit that the toString() process for a query column would be to output the value of the first row, and when outputting, there's an implicit casting to a string.  That's not how I'd implement its toString(), but it's a possibility, and not completely outrageous.

That said, other than in this one situation, on CF query.column references the first row, whereas to reference the whole column one needs to use this syntax: query["column"].  This doesn't make a great deal of sense to me, as the syntactical difference oughtn't change the results, IMO.

I think it's safe to say that historically valueList() and query columns in general were poorly implemented (in CF I mean...)

-- 
Adam

Adam Cameron

unread,
Oct 1, 2012, 4:38:32 AM10/1/12
to ra...@googlegroups.com
 
valueList("myQuery.myColumn") what is already better, but still ugly.

I meant to ask: in what way is that "better"? I can't see any meaningful difference there?

--
Adam

Adam Cameron

unread,
Oct 1, 2012, 4:42:56 AM10/1/12
to ra...@googlegroups.com


On Monday, October 1, 2012 9:35:26 AM UTC+1, Mark Drew wrote:
I agree.  GetQuery().col is a reference to a value, not a definition of a column. But you are right in one way, how do you reference a column?


Well: no.  It already clearly is a reference to a column when what is called for is a column (eg: in valueList()). It's cast to a string in other situations. valueList() is the only function that takes a query column (OKOK, and quotedValueList()), hence this being the only time - for all intents and purposes - that that notation means "column" in CFML.

And as per my overlapping post, query["column"] definitely is a reference to the entire column.  I don't know why there's the syntax-based behavioural difference here.

--
Adam

websolete

unread,
Oct 1, 2012, 4:47:08 AM10/1/12
to ra...@googlegroups.com

I think it's safe to say that historically valueList() and query columns in general were poorly implemented (in CF I mean...)


Completely agree.  And the flaw almost always manifests itself when needing to reference a query that is not a first level variable; that is, if you have a function that returns a query (as in Adam's example), or a query in a struct or array key, you cannot use the 'query.column' syntax, and never have been able to.  It requires referencing the query with a var, and then using that, which is clunky imo.  I don't think I can recall a situation where my column was dynamic or 'complex', it was always the query and how it was being referenced.

A function along the lines of what Micha is saying is ideal, if possible:   columnValueList(query query,string column)  .  Advantages include not only being able to reference queries more flexibly, but also use vars for the column name if needed.

Michael Offner

unread,
Oct 1, 2012, 4:55:48 AM10/1/12
to ra...@googlegroups.com
in the ACF way you pass a cell value to a function and you get back the complete column list, this is something only working with this function, let say you write a custom function like this

function myValueList(any cellValue){
...
}
myCellValue(myQuery.myColumn);

you will never be able to get this work (in Railo), simply because you only have the value of the cell, but you have no idea where it comes from, but the following is simple to implement.



function myValueList(strimg queryDotColumn){
...
}
myCellValue("myQuery.myColumn");

in this case you have all info you need.

/micha






2012/10/1 Adam Cameron <adamcamero...@gmail.com>
 
valueList("myQuery.myColumn") what is already better, but still ugly.

Michael Offner

unread,
Oct 1, 2012, 5:23:14 AM10/1/12
to ra...@googlegroups.com
i think i must open a bracked here, i was trying to avoid because it gets more complicated ;-)
in my previous mail i have written that "you will never be able to get this work (in Railo)", the reason "Railo" is in bracked is because you can get this working in ACF, because there is a difference here in Railo and ACF.

take this code:
#query.firstname[1]# #query.lastname#
first expression address the query then the column and then the first row and second expression only the query and column right, then when this column is used it is converted at runtime, in this case it gets the currentrow from the column, right?
so when you take that, valueList is not getting the value of the cell, it is getting the column, so it is easy to return the full column, right?
yes, this is how ACF is working, but we decided to go a other way from beginning.
in Railo this expression
#query.lastname# 
gets the query and then then value of the currentrow of the column "lastname", you don't have the column object as you have in ACF.

Why is Railo working this way?
Performance! in 99.9999...%  of the cases you address query columns this way "query.column" and you wanna have the value and nothing else and because of that the Railo compiler has optimized exact this expression, with the only downsite that this expression no longer reference the source column. (in fact it is a little bit more complicated, because the compiler has no idea that "query.column" address a query, but explaining this in detail will make us loose the focus)
 most cf developer are not aware of this syntax #query.column[row]# and never use it.
so for most cfdeveloper this #query.column# is returning a value (in ACF and Railo), not a column. from that point of view the function valueList makes no sense.

/micha





2012/10/1 Adam Cameron <adamcamero...@gmail.com>


Adam Cameron

unread,
Oct 1, 2012, 5:30:22 AM10/1/12
to ra...@googlegroups.com


On Monday, October 1, 2012 9:47:11 AM UTC+1, websolete wrote:

A function along the lines of what Micha is saying is ideal, if possible:   columnValueList(query query,string column)  .  Advantages include not only being able to reference queries more flexibly, but also use vars for the column name if needed.

Yep, it seems reasonable to just leave valueList() as is here, given the caveats Micha offers in the other post.

I'd perhaps go this route though:  queryGetColumn(Query query, String column) , which returns either some sort of column object, or just an array (there might be benefits of the former over the latter, but I can't think of them having given it a massive 10sec thought).  From there, if one wants a list, one can just use arrayToList().  There's no need to have a special function just to extract the column as a list: have a function to extract the column, and what one can do with it after that is more flexible.

--
Adam

Adam Cameron

unread,
Oct 1, 2012, 5:31:03 AM10/1/12
to ra...@googlegroups.com
Cheers for this clarification Micha: it all makes a lot of sense, and I def see why you went the way you did here.

Gert Franz

unread,
Oct 1, 2012, 5:30:38 AM10/1/12
to ra...@googlegroups.com
But on the other hand, what is the difference between functionThatReturnsAQuery().column and qry.column? IMHO valuelist should work with both.

--
Gert Franz
Sent from somewhere with my iPhone

websolete

unread,
Oct 1, 2012, 5:34:35 AM10/1/12
to ra...@googlegroups.com

But on the other hand, what is the difference between functionThatReturnsAQuery().column and qry.column? IMHO valuelist should work with both.

Agreed.  But what about struct.that.holds.query.column?  I, for one, use that frequently, despite always running into a bit of trouble in ACF with query of queries and valuelist() both.

Adam Cameron

unread,
Oct 1, 2012, 5:39:11 AM10/1/12
to ra...@googlegroups.com


On Monday, October 1, 2012 10:34:39 AM UTC+1, websolete wrote:

But on the other hand, what is the difference between functionThatReturnsAQuery().column and qry.column? IMHO valuelist should work with both.

Agreed.  But what about struct.that.holds.query.column?  I, for one, use that frequently, despite always running into a bit of trouble in ACF with query of queries and valuelist() both.

From what Micha said before, functionThatReturnsAQuery().column is not referencing a COLUMN in Railo, it really is just a ref to the value @ currentRow.  So that simply won't work.

What needs to work is that valueList() accepts any expression that returns *a column*, and to have some function that actually *does* return a column.  And this answers my question from my earlier post as to whether queryGetColumn() should return a column or an array: it should return the column.

--
Adam

Michael Offner

unread,
Oct 1, 2012, 5:42:00 AM10/1/12
to ra...@googlegroups.com
when you read my previous explanation on how railo is handling columns different to ACF, you perhaps are thinking, how the hell is the function valuelist working if there is no column info, the answer is very simple, the parameter type of the function valueList is "expression_string", so if the compiler has a "expression string" it converts the given parameter expression to a string. in other words in converts this
valueList(query.column)
to
valueList("query.column")

if we support any expression the implementation for valueList get more complicated and slower, but of course it is possible,

/micha

2012/10/1 Gert Franz <ge...@getrailo.com>

websolete

unread,
Oct 1, 2012, 5:42:31 AM10/1/12
to ra...@googlegroups.com
I see.  Just a difference in how I'd like it to work vs. how it can/should work in the big picture.

Michael Offner

unread,
Oct 1, 2012, 5:52:25 AM10/1/12
to ra...@googlegroups.com
of course Railo also has also a query column object
http://www.getrailo.org/javadoc/railo/runtime/type/QueryColumn.html
the Railo interpreter does not this optimization *, so
evaluate("query.column")
returns a query column object and not the value, so we could change railo very easy that it works the same way as ACF, but there is no plan to do so ;-)
but i think it should return a array, not the querycolumn object, simply because if user do this
dump(queryGetColumn(...)); they only see the current row value.



* we plan to merge the compiler and interpreter code in one of the next releases, so the expressions compiler and the interpreter will use the same parser soon.

/micha


2012/10/1 Adam Cameron <adamcamero...@gmail.com>


Michael Offner

unread,
Oct 1, 2012, 5:57:00 AM10/1/12
to ra...@googlegroups.com
perhaps we should do both, support valueList the same way OBD does and add the function queryGetColumn, but marking the function valueList/QuotedValueList as deprecated.
if railo still use the simple parser for reading the string expression given as input to valueList and only use the interpreter to read, when the simple parser fails, this change would not have a performance impact on the regular use of valueList.

/micha


2012/10/1 websolete <webs...@gmail.com>

Adam Cameron

unread,
Oct 1, 2012, 5:57:26 AM10/1/12
to ra...@googlegroups.com


On Monday, October 1, 2012 10:52:27 AM UTC+1, Michael Offner wrote:
but i think it should return a array, not the querycolumn object, simply because if user do this
dump(queryGetColumn(...)); they only see the current row value.


Surely that's only the case because currently dump() doesn't know what a query column is, so relies on some sort of cast-to-string behaviour, which returns the first row's value (that's a guess).  However if you have functions that return query columns as a return type, this implies dump() has to know how to deal with one of those as well, and needs to be updated to correctly dump the column?

--
Adam

Michael Offner

unread,
Oct 1, 2012, 6:09:36 AM10/1/12
to ra...@googlegroups.com
querycolumn is handled as simple type and complex type a the same time in Railo and ACF, BUT the simple type is preferred, also ACF will outputs the value in this case, i'm sure you have done the following at least 1000 times in ACF and you never have expected to see the entire column.
<cfdump var="#query.column#">

Railo has a other exampe for this, the function getTemplatePath in Railo returns a "ValueArray" that is working similar as the queryColumn, but in this case the complex type is prefered.
so you can do:
path=getTemplatePath()
...
#path#
or
#path[1]#
but
dump(path)
outputs the array

/micha





2012/10/1 Adam Cameron <adamcamero...@gmail.com>


Michael Offner

unread,
Oct 1, 2012, 6:44:26 AM10/1/12
to ra...@googlegroups.com
what you think about adding the function "queryColumn" that can also be used as member functionwith the following pattern:
queryColumn(columnName,closure)
as second parameter you can define a clsoure for example for quotiung every value, this will make the function quotedValueLust obsolote.

example:
col=queryColumn(qry, function(value){...});
col=query.column(function(value){...});


/micha



2012/10/1 Michael Offner <mic...@getrailo.com>

Gert Franz

unread,
Oct 1, 2012, 7:15:38 AM10/1/12
to ra...@googlegroups.com

Wouldn’t it be more consistent to call it queryGetColumn(), and query.getColumn() ?

 

Greetings from Switzerland

Gert Franz

 

Railo Technologies      Professional Open Source

skype: gert.franz         ge...@getrailo.com

+41 76 5680 231           www.getrailo.com

Michael Offner

unread,
Oct 1, 2012, 7:25:52 AM10/1/12
to ra...@googlegroups.com
nope, for consistent i have removed the "get", get in bif names is rare.
for example queryColumnList not queryGETColumnList.

/micha

2012/10/1 Gert Franz <ge...@getrailo.com>

Wouldn’t it be more consistent to call it queryGetColumn(), and query.getColumn() ?

Mark Drew

unread,
Oct 1, 2012, 8:24:32 AM10/1/12
to ra...@googlegroups.com
+1

Mark Drew

 
Railo Technologies Professional Open Source

Michael Offner

unread,
Oct 1, 2012, 11:36:49 AM10/1/12
to ra...@googlegroups.com
after thinking a little bit more abouit the name, i thnk queryColumn is not a good choice, because we have the function queryColumnList and queryColumnArray.
of course this functions should be named queryColumnNamesAsList/queryColumnNamesAsArray, but we cannot change this.
i think we should name the function queryColumnData, so it is clear what this function return.

/micha

2012/10/1 Mark Drew <ma...@getrailo.com>

Mark Drew

unread,
Oct 1, 2012, 11:55:48 AM10/1/12
to ra...@googlegroups.com
+10

Mark Drew
 
Railo Technologies Professional Open Source
skype: mark_railo ma...@getrailo.com
+44 7971 852296 http://www.getrailo.com

Michael Offner

unread,
Oct 1, 2012, 12:02:32 PM10/1/12
to ra...@googlegroups.com
done
https://issues.jboss.org/browse/RAILO-2084

/micha

2012/10/1 Mark Drew <ma...@getrailo.com>
+10

Adam Cameron

unread,
Oct 1, 2012, 12:04:48 PM10/1/12
to ra...@googlegroups.com
Yep, that all sounds pretty solid to me.

Nice one.

--
Adam


On Monday, October 1, 2012 4:36:51 PM UTC+1, Michael Offner wrote:
after thinking a little bit more abouit the name, i thnk queryColumn is not a good choice, because we have the function queryColumnList and queryColumnArray.
of course this functions should be named queryColumnNamesAsList/queryColumnNamesAsArray, but we cannot change this.
i think we should name the function queryColumnData, so it is clear what this function return.

/micha
 
[...]

Michael Offner

unread,
Oct 4, 2012, 11:42:46 AM10/4/12
to ra...@googlegroups.com
FYI
following ticket is now resolved

mean valueList,valueArray and quotedValueList working now with any expression and we could also improve performance!

/micha



2012/10/1 Adam Cameron <adamcamero...@gmail.com>
Yep, that all sounds pretty solid to me.

Adam Cameron

unread,
Oct 4, 2012, 11:47:45 AM10/4/12
to ra...@googlegroups.com


On Thursday, October 4, 2012 4:42:48 PM UTC+1, Michael Offner wrote:
FYI
following ticket is now resolved


Cool!

 
mean valueList,valueArray and quotedValueList working now with any expression and we could also improve performance!


Doubly cool!

I'm pleased I raised it now.

Thanks mate.

--
Adam

 
Reply all
Reply to author
Forward
0 new messages