tracker issue : CF-4137970

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

QueryNew does not enforce datatypes, inconsistent with QueryAddColumn

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

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

Created: 04/10/2016

Components: Database, General

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win All

Vote Count: 0

Duplicate ID:	CF-4117243

Problem Description:

The datatypes specified in QueryNew are not enforced. If data is added to the query that can't be converted to the specified datatype, then it's just added as a string, instead of throwing an exception. This is in contrast with QueryAddColumn, which strictly enforces the datatype specified.

Affects CF 11 Update 7.

Also affects CF 10 Update 18, although in CF 10, QueryAddColumn completely ignores datatypes (see bug #4137969).

Steps to Reproduce:

Consider this code:

<!--- Create a query using QueryNew --->
<cfset firstQuery = QueryNew("id","integer",[["1"],["hello"],["3"]])>
<cfdump var=#firstQuery#>
<cfdump var=#SerializeJSON(firstQuery)#>

<!--- Create a query using QueryAddColumn --->
<cfset secondQuery = QueryNew("")>
<cfset QueryAddColumn(secondQuery,"int","integer",["1","hello","3"])>
<cfdump var=#secondQuery#>
<cfdump var=#SerializeJSON(secondQuery)#>

Actual Result:

1	1
2	hello
3	3

followed by ColdFusion exception on line 8:
Invalid data hello for CFSQLTYPE CF_SQL_INTEGER.

Expected Result:

Using QueryNew should also throw an exception when data of the wrong type is added.

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

Watson Bug ID:	4137970

External Customer Info:
External Company:  
External Customer Name: Legorol San
External Customer Email:  
External Test Config: My Hardware and Environment details: Windows 10 Pro 64-bit



This also affects QueryAddRow, which also doesn't enforce the datatypes of the query columns. It just adds data as strings instead of throwing an exception, the data can't be converted.
Comment by External U.
3111 | April 11, 2016 05:43:26 AM GMT
Thanks Legorol San for the information. We will take care of that as well.
Comment by Nimit S.
3112 | April 11, 2016 05:46:19 AM GMT
Hi Nimit, Please see CF-4117243, which I've already logged in February. Thanks!, -Aaron
Comment by External U.
3113 | April 28, 2016 02:43:19 AM GMT