Lucee vs Adobe ColdFusion columnList vs getColumnList vs getmetadata

I have a general section which dynamically displays reports, which are preconfigured in a certain way. 

There are some totals and data rows which are not part of the metrics so net result is I had some CF code looking at the column lists and displaying appropriately. 

Turns out there are very different results between Lucee and Adobe Coldfusion, for this example, it's important to create a sample table like so: 

CREATE TABLE testtable(

[Col1] [varchar](50) NULL,

[ACol2] [varchar](50) NULL

)

so that ACol2 is actually alphabetically before Col1. 


Then run this

<cfquery datasource="aTestDSN" name="qry">

select * from testtable

</cfquery>

<cfset columns = "">

<cfloop array="#getmetadata(qry)#" item="aryItem">

<cfset columns = listappend(columns, aryItem.Name)>

</cfloop>

<table>

<tr><td>getmetadata</td><td><cfoutput>#columns#</cfoutput></td></tr>

<tr><td>ColumnList</td><td><cfoutput>#qry.ColumnList#</cfoutput></td></tr>

<tr><td>arrayToList(qry.getColumnList())</td><td><cfoutput>#arrayToList(qry.getColumnList())#</cfoutput></td></tr>

</table>



Lucee Output

getmetadata
Col1,ACol2
ColumnListCOL1,ACOL2
arrayToList(qry.getColumnList())

Adobe Coldfusion Output:

getmetadataCol1,ACol2
ColumnListACOL2,COL1
arrayToList(qry.getColumnList())COL1,ACOL2


So, in my case, for a solution that works on both, I need to use the getmetadata. 


Comments

Popular posts from this blog

cf_sql_timestamp vs cf_sql_date vs getdate()

Global SQL Procedure, System Objects and sp_ms_marksystemobject

Ghost Records, Card Recon and PCI Compliance