tracker issue : CF-4198322

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

QueryExecute Error When Parsing SQL Including Literal Strings with Colons

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Clifton Johnston / Clifton Johnston ()

Created: 02/08/2017

Components: Database, CFQuery

Versions: 2016,11.0

Failure Type: Others

Found In Build/Fixed In Build: ColdFusion 11 Update 10 / 303807

Priority/Frequency: Normal /

Locale/System: / Win 2008 Server R2 64 bit

Vote Count: 2

Problem Description: This error occurs when the SQL statement includes literal strings (enclosed in single quotes) containing a colon (:) followed by a space. 

Steps to Reproduce: Example code:

qGetEmailTemplate = queryExecute("
		SELECT Introduction, Subject, EmailBody, FromAddress, ActionType
		FROM Templates
		WHERE Title = 'Customer Support: Something or Other' 
		AND Active = 1
	",{},
	{ 
		datasource = Request.ds
	});

Actual Result: Error received: "Error occurred while parsing SQL query string. Space is not allowed after parameter prefix ':'"

Expected Result: No error, and possibly, records returned, etc. CF shouldn't be attempting to parse for parameters within the string literals.

Any Workarounds: Replacing the string literal with an actual parameter holding the value of the string literal works:

qGetEmailTemplate = queryExecute("
		SELECT Introduction, Subject, EmailBody, FromAddress, ActionType
		FROM Templates
		WHERE Title = :emailTitle 
		AND Active = 1
	",{ emailTitle = 'Customer Support: Something or Other' },
	{ 
		datasource = Request.ds
	});

Attachments:

Comments:

This issue is fixed now. The fix for this issue will be available as part of next update of ColdFusion 11 and ColdFusion 2016.
Comment by Nimit S.
1221 | September 14, 2017 06:31:29 AM GMT