Setting the Column List of a query without using QofQs and QueryExecute()?

Dear Lucee,

I am currently migrating my generic Query Of Queries (QofQs) function to use filters instead - QueryFilter(), QuerySort(), QuerySlice(), etc.

I use a dynamic variable to set the Column List of a query to return only the columns specified.

For example:

local.columnList = Len(Trim(arguments.ColumnList)) ? arguments.ColumnList : arguments.Query.columnlist;

local.sql = 'SELECT ' & local.columnList & ' FROM arguments.query WHERE 1 AND 1' & local.queryParamList & ' ' & arguments.OrderByStatement;
local.queryOfQuery = QueryExecute( SQL = UCase(local.sql), QueryOptions = { dbtype = 'query', maxrows = local.maxrows } );

Do you know of a way I can set the Column List of a query without using QofQs and QueryExecute()?

It would be nice to have a query function that can set the Column List of a query - filtered or unfiltered, for example:

local.filteredQuery.setColumnList('col1,col5,col9');

I have had a look at query.columnList(), query.columnData(), ListFilter(), etc.

query.columnList() would have been a good function to set a new Column List but is instead used as a change delimiter function of a column list.

Many thanks

=========================
OS: Linux and Windows
Java Version: 8
Tomcat Version: 9
Lucee Version: 5.3.7.47
Coldbox: 6

Try this

https://docs.lucee.org/reference/functions/querymap.html

Many thanks Webonix for pointing me in the right direction.

Will look at QueryMap().

Thanks Webonix, that worked really well.

Example:

local.filteredQuery.map(function(row) {
     return row;
}, QueryNew(arguments.columnList)); // custom column list

Cool

I did not know about passing in a query as second argument- we both learnt something :slight_smile:

1 Like