Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): Vinicius P. / ()
Created: 12/03/2019
Components: REST Services
Versions: 2018
Failure Type: Incorrectly functioning
Found In Build/Fixed In Build: 2018.0.04.314546 /
Priority/Frequency: Normal / Most users will encounter
Locale/System: English / Windows 10
Vote Count: 1
Problem Description: When returning a timestamp from a query on a rest service the format changes from yyyy-mm-dd hh:nn:ss to mmmm, dd yyyy hh:nn:ss
Steps to Reproduce:
Create a rest service with a CFC called restService.cfc.
Path: rest/ws/restService/
Call any of the functions with rest with method = "POST"
restService.cfc :
<cfcomponent rest="true" restpath="restService">
<cfprocessingdirective pageencoding="utf-8">
<cffunction name="returnDate" restPath="returnDate" access="remote" returntype="String" httpmethod="POST" produces="application/JSON">
<cfset myQuery = QueryNew("Name, Date", "VarChar, Timestamp")>
<!--- Make two rows in the query --->
<cfset QueryAddRow(MyQuery, 1)>
<!--- Set the values of the cells in the query --->
<cfset QuerySetCell(myQuery, "Name", "The Wonderful World of CMFL", 1)>
<cfset QuerySetCell(myQuery, "Date", now(), 1)>
<!---
<cfdump var="#myQuery#" abort="true">
--->
<cfreturn serializeJSON(myQuery, 'struct')>
</cffunction>
<cffunction name="returnDateFromQuery" restPath="returnDateFromQuery" access="remote" returntype="query" httpmethod="POST" produces="application/JSON">
<cfset myQuery = QueryNew("Name, Date", "VarChar, Timestamp")>
<!--- Make two rows in the query --->
<cfset QueryAddRow(MyQuery, 1)>
<!--- Set the values of the cells in the query --->
<cfset QuerySetCell(myQuery, "Name", "The Wonderful World of CMFL", 1)>
<cfset QuerySetCell(myQuery, "Date", now(), 1)>
<!---
<cfdump var="#myQuery#" abort="true">
--->
<cfreturn myQuery>
</cffunction>
</cfcomponent>
Actual Result:
[{"NAME":"The Wonderful World of CFML","DATE":"December, 03 2019 09:42:04"}]
Expected Result:
[{"NAME":"The Wonderful World of CFML","DATE":"2019-12-03 09:42:04"}]
Any Workarounds:
To get the expected result at the rest response I need to change the datatype from timestamp to varchar.
If you uncomment any of the dump tags that are just before the function return you can see that the format is correct up until this point.
Attachments:
Comments: