tracker issue : CF-4126384

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

[ANeff] Bug for: CF11 vs CF2016 wrt queryAddColumn()

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

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

Created: 03/09/2016

Components: Language

Versions: 2016

Failure Type: Unspecified

Found In Build/Fixed In Build: RC1_v12 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Win All

Vote Count: 0

Listed in the version 2016.0.01.298513 Issues Fixed doc
Verification notes: verified_fixed on July 30, 2017 using build 2016.0.01.298513
In CF11, queryAddColumn()'s default column type is "object" [aka unspecified] (good)

In CF2016, queryAddColumn()'s default column type is "object" [aka unspecified] if query has no rows (good)
In CF2016, queryAddColumn()'s default column type is "varchar" if query has rows (bad)

Repro:

<cfscript>
  q = queryNew("col1");
  queryAddColumn(q, "col2", []);//add column when query has 0 rows
  queryAddRow(q);
  writeDump(getMetadata(q));
  querySetCell(q, "col1", {foo="foo"}, 1);
  querySetCell(q, "col2", {bar="bar"}, 1);
  writeDump(q);
</cfscript>

Actual and expected result in CF11 and CF2016: Both column types are unspecified (aka "object") and the 'foo' and 'bar' structs are inserted into the query.

<cfscript>
  q = queryNew("col1");
  queryAddRow(q);
  queryAddColumn(q, "col2", []);//add column when query already has a row
  writeDump(getMetadata(q));
  querySetCell(q, "col1", {foo="foo"}, 1);
  querySetCell(q, "col2", {bar="bar"}, 1);//throws: Invalid data {BAR={bar}} for CFSQLTYPE CF_SQL_VARCHAR
  writeDump(q);
</cfscript>

Actual and expected result in CF11: Both column types are unspecified (aka "object") and the 'foo' and 'bar' structs are inserted into the query.

Actual result in CF2016:
- col1's column type is unspecified (aka "object") (good)
- 'foo' struct is inserted into query (good)
- col2's column type is varchar (bad)
- 'bar' struct throws "Invalid data {BAR={bar}} for CFSQLTYPE CF_SQL_VARCHAR" when inserting into query

Expected result in CF2016: Match CF11

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

Watson Bug ID:	4126384

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email: adobelabs@itisdesign.com
External Test Config:

Attachments:

Comments:

Adding BUG AUDIT TRAIL ********action: updated fieldName: Fix By Product Milestone newValue: HF1 oldValue: HF2 oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-29 12:10:18.0 action: updated fieldName: Fix By Milestone newValue: Post Release oldValue: Blank oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-17 10:20:41.0 action: updated fieldName: Fix By Product Milestone newValue: HF2 oldValue: Blank oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-17 10:20:41.0 action: updated fieldName: Reason newValue: Fixed oldValue: Blank oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-17 10:18:37.0 action: updated fieldName: Fixed By newValue: himar oldValue: Blank oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-17 10:18:37.0 action: updated fieldName: Date Fixed newValue: 2016-02-17 02:18:37.0 oldValue: Blank oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-17 10:18:37.0 action: updated fieldName: Changelist newValue: 298053 oldValue: Blank oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-17 10:18:37.0 action: updated fieldName: Status newValue: ToTest oldValue: Unverified oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-17 10:18:37.0 action: updated fieldName: QE Assigned newValue: nimsharm oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-17 05:06:01.0 action: updated fieldName: Owner newValue: nimsharm oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-17 05:06:01.0 action: updated fieldName: Priority newValue: 2 oldValue: 0 oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-02-16 15:15:23.0 action: updated fieldName: Dev Assigned newValue: himar oldValue: awdhesh oprid: himar recordName: RQ_DEFECT timpestamp: 2016-02-16 08:57:22.0
Comment by CFwatson U.
4331 | March 09, 2016 01:51:17 AM GMT
Added By: PreRelease User User Name:Aaron Neff Note Added: Entered Bug. Date Added :2016-02-12 21:58:53.0
Comment by CFwatson U.
4332 | March 09, 2016 01:51:18 AM GMT
This issue is fixed now. The fix will be available as part of upcoming update of ColdFusion 2016.
Comment by Nimit S.
4333 | March 27, 2016 05:55:32 AM GMT
When run on Linux (64-bit CentOS 7 w/1.8.071 JVM)... we're seeing (with original/not-updated CF2016 release) that the type for 'col2' is consistently reported as 'varchar', contrary to the original post - but that the crash is the same... which indicates that there's another bug - QuerySetCell is not checking for type agreement A similar case also fails - hopefully this is also resolved in the upcoming patch: foo = ArrayNew(1); ArrayAppend(foo,{name='first'}); ArrayAppend(foo,{name='second'}); qry = QueryNew(""); QueryAddColumn(qry,"test1",foo); // crash - Invalid data {NAME={first}} for CFSQLTYPE CF_SQL_VARCHAR. WriteDump(qry);
Comment by External U.
4334 | April 15, 2016 12:10:14 PM GMT
Also... for completeness - I suggest adding a new 'Any' option for the type argument to QueryAddColumn - this would remove any ambiguity and prevent unneeded attempts at type checking. It would be reasonable (and probably good) to throw exceptions if a Query of Queries attempts to use a column of type 'Any' in a WHERE clause or aggregate function (if field 'x' is a field containing structs, Max(x) is clearly silly)
Comment by External U.
4335 | April 15, 2016 12:27:29 PM GMT
Verified, on April 12, 2016, that this is fixed in CF2016 Update 1 (build 2016.0.01.298513). Thanks!, -Aaron
Comment by Aaron N.
4336 | July 30, 2017 06:23:28 PM GMT