tracker issue : CF-4207857

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

[ANeff] Bug for: Query metadata broken if 'default' (type unspecified) column added first

| View in Tracker

Status/Resolution/Reason: To Fix//BugVerified

Reporter/Name(from Bugbase): Aaron N. / ()

Created: 04/06/2020

Components: Language, Query Functions

Versions: 2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2018.0.08.318307 /

Priority/Frequency: Normal / Very few users will encounter

Locale/System: / Windows 10 64 bit

Vote Count: 0

Issue: Query metadata becomes partially broken, if specifically-typed columns are added after an unspecifically-typed column. Next, the query's metadata becomes further broken if a QoQ is ran against it.

Repro:

Application.cfc:
-----------
component {THIS.name = "MyApp";}
-----------

index.cfm
-----------
<cfscript>
  columnNameAndTypeList = ["object","integer","bigint","double","decimal","varchar","binary","bit","time","date","timestamp"];
  myQuery1 = queryNew(columnNameAndTypeList.toList(), columnNameAndTypeList.toList());//Columns w/ specified types are added here
  myQuery1.addColumn("default", []);//Column w/ unspecified (i.e. 'default') type is added here
  myQuery1.addRow();
  for(columnMetadata in getMetadata(myQuery1)) {
	  typeName = columnMetadata.keyExists("typeName") ? columnMetadata.typeName : 'NULL';
	  writeOutput(columnMetadata.name & ' <span style="color:#(typeName IS NOT 'NULL') and typeName.len()?'green':'red'#;">[' & typeName & ']</span><br>');
  }
  writeOutput("-----------<br>");
  queryExecute("SELECT * FROM myQuery1", [], {dbtype="query"});
  for(columnMetadata in getMetadata(myQuery1)) {
	  typeName = columnMetadata.keyExists("typeName") ? columnMetadata.typeName : 'NULL';
	  writeOutput(columnMetadata.name & ' <span style="color:#(typeName IS NOT 'NULL') and typeName.len()?'green':'red'#;">[' & typeName & ']</span><br>');
  }
  writeOutput("===========<br>");
  myQuery2 = queryNew("default");//Column w/ unspecified (i.e. 'default') type is added here
  for(columnNameAndType in columnNameAndTypeList) {
	  myQuery2.addColumn(columnNameAndType, columnNameAndType, []);//Columns w/ specified types are added here
  }
  myQuery2.addRow();
  for(columnMetadata in getMetadata(myQuery2)) {
	  typeName = columnMetadata.keyExists("typeName") ? columnMetadata.typeName : 'NULL';
	  writeOutput(columnMetadata.name & ' <span style="color:#(typeName IS NOT 'NULL') and typeName.len()?'green':'red'#;">[' & typeName & ']</span><br>');
  }
  writeOutput("-----------<br>");
  queryExecute("SELECT * FROM myQuery2", [], {dbtype="query"});
  for(columnMetadata in getMetadata(myQuery2)) {
	  typeName = columnMetadata.keyExists("typeName") ? columnMetadata.typeName : 'NULL';
	  writeOutput(columnMetadata.name & ' <span style="color:#(typeName IS NOT 'NULL') and typeName.len()?'green':'red'#;">[' & typeName & ']</span><br>');
  }
</cfscript>
-----------

Actual Result:

object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [NULL] <= "NULL" should be "JAVA_OBJECT" (CF-4207855)
-----------
object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [NULL] <= "NULL" should be "JAVA_OBJECT" (CF-4207855)
===========
default [] <= "" should be "JAVA_OBJECT"
object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
-----------
default [NULL] <= "NULL" should be "JAVA_OBJECT"
object [NULL] <= "NULL" should be "JAVA_OBJECT"
integer [NULL] <= "NULL" should be "INTEGER"
bigint [NULL] <= "NULL" should be "BIGINT"
double [NULL] <= "NULL" should be "DOUBLE"
decimal [NULL] <= "NULL" should be "DECIMAL"
varchar [NULL] <= "NULL" should be "VARCHAR"
binary [NULL] <= "NULL" should be "BINARY"
bit [NULL] <= "NULL" should be "BIT"
time [NULL] <= "NULL" should be "TIME"
date [NULL] <= "NULL" should be "DATE"
timestamp [NULL] <= "NULL" should be "TIMESTAMP"

Expected Result:

object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [JAVA_OBJECT]
-----------
object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [JAVA_OBJECT]
===========
object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [JAVA_OBJECT]
-----------
object [JAVA_OBJECT]
integer [INTEGER]
bigint [BIGINT]
double [DOUBLE]
decimal [DECIMAL]
varchar [VARCHAR]
binary [BINARY]
bit [BIT]
time [TIME]
date [DATE]
timestamp [TIMESTAMP]
default [JAVA_OBJECT]

Verified in CF2016 Update 1 (build 2016.0.01.298513) and CF2018 Update 8 (build 2018.0.08.318307) and later.

Attachments:

Comments: