Title:
String methods process single quotes differently when CFSet is used inside a CFQuery block
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/
Reporter/Name(from Bugbase): Tim Parker / Tim Parker (Tim Parker)
Created: 10/02/2014
Components: Core Runtime
Versions: 9.0.1
Failure Type: Data Corruption
Found In Build/Fixed In Build: 9.0.1 /
Priority/Frequency: Normal / Some users will encounter
Locale/System: English / Windows 7
Vote Count: 0
Duplicate ID: CF-3585643
Problem Description: If CFSet is used within a CFQuery block, string functions double any single quotes in their return values
Steps to Reproduce:
>> set up a datasource 'scratch' referring to a SQL Server database (or update the query in this code to be a no-op for another database flavor)
>> run the following code - observe that the 'normal result' and 'result from inside CFQuery' values are different
<cfscript>
foo = "I can't wait";
WriteOutput("(before): #foo#<br />");
resOutside = "you #Mid(foo,2,99999)# - I can't either";
WriteOutput("(normal result): #resOutside#<br />");
</cfscript>
<cfquery name="fubar" datasource="scratch">
<cfset resInside = "you #Mid(foo,2,99999)# - I can't either">
select 'hello' as greeting
</cfquery>
<cfscript>
WriteOutput("(result from inside CFQuery): #resInside#");
</cfscript>
Actual Result:
(before): I can't wait
(normal result): you can't wait - I can't either
(result from inside CFQuery): you can''t wait - I can't either
>>> Observe that the "can't" from the CFSet inside the CFQuery becomes "can''t" (doubled apostrophe)
>> Also observe that the "I can't either" in both assignments is NOT affected
>>> NOTE: Simililar behavior observed when Replace or ReplaceList is used with the assignments, leading to the assumption that most (if not all) string methods are similarly affected.
For purposes of this example, the query was reduced to a no-op to show that the query itself is not the problem. In the original case, the method used was 'Replace' and the result was used in an 'update' query - resulting in trouble later when the updated column contained WDDX
Expected Result:
- resulting values should be identical
Any Workarounds:
- refactor code to avoid use of CFSet with string methods inside CFQuery blocks
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3834866
External Customer Info:
External Company:
External Customer Name: TParker
External Customer Email:
External Test Config: My Hardware and Environment details:
CF9 on Windows 7 (64-bit) 1.7.67 JVM
CF11 on Linux (CentOS 6.5, 64-bit), 1.7.60 JVM
Attachments:
Comments: