As the title says, multiple updates were released for ColdFusion today. One is an update to ColdFusion 10 (details may be found here) and the other is a rather big update to ColdFusion 11, Update 5.
You can see the complete list of bug fixes here: Bugs fixed in ColdFusion 11 Update 5. I want to call out one bug in particular that I'm happy is fixed: 3818767: Serialization of query does not respect case.
ColdFusion 11 added a new way to serialize queries - "struct". You could pass this to the serializeJSON function or simply specify it as a default in Application.cfc. I discussed this in detail here: ColdFusion 11’s new Struct format for JSON (and how to use it in ColdFusion 10). While this was cool, the columns were all uppercased when the JSON string was generated. So for example:
[{"NAME":"ray","AGE":30}]
While still a better format, most people prefer lowercase. Now ColdFusion let's you specify a setting to tell ColdFusion to use the same case you used in the query. To enable this feature, add this.serialization.preserveCaseForQueryColumn="true"
to your Application.cfc file. Here is a complete example.
component {
this.name="root";
this.serialization.serializequeryas="struct";
this.serialization.preserveCaseForQueryColumn="true";
}
Now your query will serialize and respect the case you used when writing your SQL.
Adobe forgot to update the docs for this, but luckily I still have edit access to the wiki. You can see this, and the other Application.cfc variables, here at the reference: Application variables
Archived Comments
Hi Raymond
I've been struggling with this for a while.
I've added:
<cfset this.serialization.preservecaseforstructkey="true">
<cfset this.serialization.serializequeryas="struct">
<cfset this.serialization.preservecaseforquerycolumn="true">
But my JSON still returns in uppercase.
Here is my query:
<cfquery name="somequery" datasource="#application.db#">
select zone_country_ID, country_name
From tblCountries
order by zone_country_ID
</cfquery>
Here is my data:
<cfset reslistcountryinfo["data"]="somequery">
zone_country_ID, country_name are both being returned in UPPERCASE? In the DB they are stored as displayed here.
Do you have any advice for me?
Well first off, I assume your last line didn't mean to use quotes around somequery, otherwise you would return the exact string.
Outside of that, I've seen CF cache application settings. If you can restart CF, try that, _and_, edit a file. Any file. Like add a new line. Restart CF and see if that helps. In a pinch, rename the name of the application.