tracker issue : CF-4117243

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

[ANeff] Bug for: queryNew() not respecting column type

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 02/12/2016

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final / 303807

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 1

Duplicate ID:	CF-4137970

queryNew() does not respect column type

Repro:

<cfscript>
  q = queryNew("foo", "integer", [["bar"]]);
  writeDump(q);
</cfscript>

Actual result: "bar" is set into integer column

Expected result: exception "Invalid data bar for CFSQLTYPE CF_SQL_INTEGER"

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

Watson Bug ID:	4117243

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

This will have backward-compat issues
Comment by Vamseekrishna N.
4783 | June 08, 2016 03:27:26 AM GMT
Aaron, It will have backward compatibility issues. We recommend not to fix this issue. -Nimit
Comment by Nimit S.
4784 | June 23, 2016 12:20:14 AM GMT
Hi Vamsee and Nimit, If the issue is not fixed, then queryNew()'s rowData parameter could not be recommended as a replacement for querySetCell(). Could you please consider for Aether? Thanks!, -Aaron
Comment by External U.
4785 | July 05, 2016 03:15:29 AM GMT
Good code would expect queryNew("foo", "integer", [["bar"]]) to throw an exception. Therefore, I think backward-compat shouldn't be maintained. When column type is explicitly specified, user -expects- an error to be thrown.
Comment by External U.
4786 | July 05, 2016 03:20:06 AM GMT
Agree with Aaron's comment.
Comment by External U.
4787 | July 05, 2016 01:57:25 PM GMT
This issue is fixed now. The fix for this issue will be available as part of the next release of ColdFusion. Behavior Change after the fix: When the data type is explicitly set it is honored and if the data type is not matched, then DataTypeMismatchException is thrown. However, To maintain backward compatibility, when the data type is not set explicitly it would still allow users to set any type of value. There are 3 cases which we have taken care of: Case 1:- (Fixed now) --------------------------------- <cfscript> q = queryNew("foo", "integer", ["10b"]); writeDump(q); </cfscript> Case 2:- Due to backward compatibility issue, the following case was relaxed as per the bug fix-CF-3143550. It continues to be relaxed after the fix also. ------------------------------------------------------------------------------------------------------------------------- <cfquery name="artgal" datasource="cfartgallery"> select * from art </cfquery> <cfset artgal.artname[2] = {anyNonSimpleContent=true} /> <cfdump var="#artgal#"/> Case 3:- QuerySetCell has the data type explicitly mentioned. So, the exception is thrown in CF10/11/2016, and will continue to throw the exception. ----------------------------------------------------------------------------------------------------------------------------------------------- <cfset myQuery = QueryNew("Name, Time, Advanced", "VarChar, Time, Bit")> <!--- Make two rows in the query ---> <cfset QueryAddRow(MyQuery, 2)> <!--- Set the values of the cells in the query ---> <cfset QuerySetCell(myQuery, "Time", "9:15 AM", 1)> <cfset QuerySetCell(myQuery, "Name", {}, 1)> <cfdump var="#myQuery#">
Comment by Nimit S.
4788 | September 12, 2017 11:56:58 AM GMT