tracker issue : CF-3944215

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

queryExecute() can't parse SQL statements containing xquery

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Scott Brady / Scott Brady (Scott Brady)

Created: 02/23/2015

Components: Database

Versions: 11.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF11_Final / CF11 Update7

Priority/Frequency: Normal / Some users will encounter

Locale/System: ALL / Mac 10.10 64 bit

Vote Count: 3

Listed in the version 11.0.07.296330 Issues Fixed doc
Related Bugs:
CF-3943345 - Similar to
CF-3949417 - Similar to


Problem Description:
When using queryExecute() with a SQL statement that includes an XQuery search that contains colons, the parser breaks on the colons expecting the text after the column to be a named parameter.

Steps to Reproduce:
1) Write a SQL statement that does an XQuery search.  For example:
local.myQuery = queryExecute("
	SELECT mt1.myColumn
	FROM 
		myTable mt1
		INNER JOIN myTable2 mt2 ON mt1.joinColumn = mt2.joinColumn.value('(form[@id=sql:column(""p.formID"")]/question[@id=sql:column(""q.formQuestionID"")]/option/@id)[1]', 'NVARCHAR(35)')
					WHERE mt1.myID = :myID
				", 
				{myID: {value:100, cfsqltype:'cf_sql_int'}}, 
				{datasource:"myDSN"}
			);

Actual Result:
An exception is returned:  "Named Parameter (column) is not defined"  [NOTE that it thinks :column in the XQuery is a named parameter

Expected Result:
The query would run as expected and a result set would be returned.

Any Workarounds:
Other methods of running queries (CFML's <cfquery> and cfscript's query() can be used (even though query() uses the same format for named parameters).

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

Watson Bug ID:	3944215

External Customer Info:
External Company:  
External Customer Name: Donald
External Customer Email:  
External Test Config: My Hardware and Environment details:

Mac OS X (10.10) running Coldfusion 11 to connect to SQL Server 2014

Attachments:

Comments:

we use xquery heavily within SQL, this would be nice to have as we migrate more code to cfscript! <3
Vote by External U.
8317 | February 23, 2015 03:18:02 PM GMT
We'd love to migrate to cfscript!
Vote by External U.
8318 | March 26, 2015 01:43:01 PM GMT
The query should run and return results
Vote by External U.
8319 | March 26, 2015 01:43:24 PM GMT
CF should only treat ":column" as a param name *if* there is actually a param passed in called "column".
Comment by External U.
8312 | March 27, 2015 05:23:30 AM GMT
This issue is fixed and the fix for this issue will be available in next major release of ColdFusion.
Comment by Nimit S.
8313 | November 04, 2015 01:58:41 AM GMT
It looks like this is not fixed in CF11 Update 7 (build 11,0,07,296330). Repro (the myXMLColumn row 1 contains <myXML>foo</myXML>): queryExecute("SELECT myXMLColumn.query('(:myXQueryComment:)/myXML')FROM myTable WHERE id = :myID", {myID={value=1}}, {datasource="myDSN"}) CF11 Update 5 throws: "Named parameter (myXQueryComment) is not defined" CF11 Update 7 throws: "Space is not allowed after parameter prefix ':'" So, the error message is different - but it's still throwing an error unless I remove the "(:myXQueryComment:)" XQuery comment. Thanks!, -Aaron
Comment by External U.
8314 | December 03, 2015 05:26:13 AM GMT
*bump*
Comment by External U.
8315 | June 02, 2016 03:11:06 AM GMT
Aaron, I'm not sure if they're going to re-open this bug. I'd say create a new one -- since this issue is SLIGHTLY different (same idea, but possibly different cause), it might be worth its own bug. Also, they're probably more likely to pay a bit more attention to a new bug rather than this old one.
Comment by External U.
8316 | June 02, 2016 08:07:54 AM GMT