Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): James Moberg / James Moberg (James Moberg)
Created: 03/02/2015
Components: Database
Versions: 10.0
Failure Type:
Found In Build/Fixed In Build: Final /
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Win 2008 Server R2
Vote Count: 2
Problem Description: Performing a DISTINCT query-of-queries and sorting by column names that aren't returned should return a syntax error and not non-DISTINCT results.
Steps to Reproduce:
https://gist.github.com/JamoCA/cd4c409501ea5199cd5a
Try it here: http://www.trycf.com/gist/cd4c409501ea5199cd5a (Correctly fails w/Railo & Lucee)
<CFSET TestQuery = QueryNew("Letter,Score", "varchar,integer")>
<CFLOOP LIST="A,B,C" INDEX="thisLetter">
<CFLOOP LIST="1,2,3" INDEX="thisScore">
<CFSET QueryAddRow(TestQuery)>
<CFSET QuerySetCell(TestQuery, "Letter", ThisLetter)>
<CFSET QuerySetCell(TestQuery, "Score", ThisScore)>
</CFLOOP>
</CFLOOP>
<CFQUERY NAME="Test" DBTYPE="query">SELECT DISTINCT Letter
FROM TestQuery
ORDER BY Score</CFQUERY>
<!--- MSSQL Execution Error: ORDER BY items must appear in the select list if SELECT DISTINCT is specified --->
<h2>Distinct Letters</h2>
<p>This query should have thrown a syntax error, but Adobe ColdFusion returns duplicated rows instead.</p>
<CFDUMP VAR="#Test#">
<h2>Full Data</h2>
<CFDUMP VAR="#TestQuery#">
Actual Result: Duplicated non-DISTINCT records
Expected Result: An error. The SQL syntax is invalid.
Any Workarounds: Test CFML on an alternate ColdFusion engine to determine if valid syntax before deploying on ACF?
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3947110
External Customer Info:
External Company:
External Customer Name: James
External Customer Email:
External Test Config: My Hardware and Environment details:
Not important. Tested it on multiple installations of ColdFusion 9 & 10.
Attachments:
Comments: