tracker issue : CF-4137969

select a category, or use search below
(searches all categories and all time range)
Title:

QueryAddColumn ignores the datatype specified

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/TooManySideEffects

Reporter/Name(from Bugbase): Legorol San / Legorol San (Legorol San)

Created: 04/10/2016

Components: Database

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win All

Vote Count: 0

Problem Description:

The datatype argument of QueryAddColumn is ignored in most cases, in contrast with the datatypes argument of QueryNew.  It seems that even if a datatype argument is supplied to QueryAddColumn, it adds the data to the query as strings.

Affects CF 10 Update 18. Doesn't affect CF 11 Update 7. Possibly related to bug #3146604.


Steps to Reproduce:

Consider this code:

<!--- Create a query using QueryAddColumn --->
<cfset query = QueryNew("")>
<cfset QueryAddColumn(query,"int","integer",["1","2","3","4"])>
<cfset QueryAddColumn(query,"bool","bit",["true","false","yes","no"])>
<cfset QueryAddColumn(query,"date","date",["1/1/2000","2 Feb 2001","2002-03-03","4/4/2003"])>
<cfset QueryAddColumn(query,"string","varchar",["eeny","meeny","miny","mo"])>

<cfdump var=#query#>
<cfdump var=#SerializeJSON(query)#>

<!--- Create a query using QueryNew --->
<cfset otherQuery = QueryNew("int,bool,date,string","integer,bit,date,varchar",[
	["1","true","1/1/2000","eeny"],
	["2","false","2 Feb 2001","meeny"],
	["3","yes","2002-03-03","miny"],
	["4","no","4/4/2003","mo"]
])>

<cfdump var=#otherQuery#>
<cfdump var=#SerializeJSON(otherQuery)#>


Actual Result:

Both the dumps of the queries and the serialized versions look very different in the two cases. In the first case, the data is (incorrectly) serialized to strings:

 	BOOL	DATE	INT	STRING
1	1	1/1/2000	1	eeny
2	0	2 Feb 2001	2	meeny
3	1	2002-03-03	3	miny
4	0	4/4/2003	4	mo

{"COLUMNS":["INT","BOOL","DATE","STRING"],"DATA":[["1","true","1/1/2000","eeny"],["2","false","2 Feb 2001","meeny"],["3","yes","2002-03-03","miny"],["4","no","4/4/2003","mo"]]}

 	BOOL	DATE	INT	STRING
1	1	{ts '2000-01-01 00:00:00'}	1	eeny
2	0	{ts '2001-02-02 00:00:00'}	2	meeny
3	1	{ts '2002-03-03 00:00:00'}	3	miny
4	0	{ts '2003-04-04 00:00:00'}	4	mo

{"COLUMNS":["INT","BOOL","DATE","STRING"],"DATA":[[1,true,"January, 01 2000 00:00:00","eeny"],[2,false,"February, 02 2001 00:00:00","meeny"],[3,true,"March, 03 2002 00:00:00","miny"],[4,false,"April, 04 2003 00:00:00","mo"]]}


Expected Result:

QueryAddColumn should respect the datatype. Expect identical query and serialization outputs in the two cases.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4137969

External Customer Info:
External Company:  
External Customer Name: Legorol San
External Customer Email:  
External Test Config: My Hardware and Environment details: Windows Server 2008 R2 Foundation 64-bit

Attachments:

Comments:

As mentioned in bug #CF-3146604, the fix for this issue is risky and can break existing applications. So, the fix will not be back ported to ColdFusion 10.
Comment by Nimit S.
3115 | April 11, 2016 05:22:21 AM GMT