8

This does not crash in ColdFusion 11, but does crash in ColdFusion 2016

SELECT  *
FROM    dbo.Roles WITH (NOLOCK)
WHERE   Code IS NOT NULL
AND     Active = 1
AND     RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) -- It's ok to look at termed employees

enter image description here

This works OK in both

SELECT  *
FROM    dbo.Roles WITH (NOLOCK)
WHERE   Code IS NOT NULL
AND     Active = 1
AND     RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) 

Is there a setting to restore the orginal behavior?

UPDATE

I thought I had a minimal example of the issue, but I didn't. Here is the complete query

    SELECT '<ul>' + STUFF (
        (
        SELECT  MIN(Role) AS "li/code", Code AS "li/span/b", 'Unsorted' AS "li/span/var"
        FROM    dbo.Roles WITH (NOLOCK)
        WHERE   Code IS NOT NULL
        AND     Active = 1
        AND     RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) -- It's ok to look at termed employees
        GROUP BY Code
        FOR XML PATH ('')
        ),
        1,0,''

    ) + '</ul>' AS xmlRole

When I turn on DB debugging: I get:

spy(http-nio-8500-exec-5)(2016/02/17 10:21:13.807)>> OK

spy(http-nio-8500-exec-5)(2016/02/17 10:21:13.807)>> Statement[4].execute(String sql, int autoGeneratedKeys)
spy(http-nio-8500-exec-5)(2016/02/17 10:21:13.807)>> sql = SELECT '<ul>' + STUFF ( ( SELECT MIN(Role) AS "li/code", Code AS "li/span/b", 'Unsorted' AS "li/span/var" FROM dbo.Roles WITH (NOLOCK) WHERE Code IS NOT NULL AND Active = 1 AND RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) -- It's ok to look at termed employees GROUP BY Code FOR XML PATH ('') ), 1,0,'' ) + '</ul>' AS xmlRole
spy(http-nio-8500-exec-5)(2016/02/17 10:21:13.807)>> autoGeneratedKeys = 1
spy(http-nio-8500-exec-5)(2016/02/17 10:21:13.807)>>    
java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near ')'. ErrorCode=102 SQLState=HY000
java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near ')'.
    at macromedia.jdbc.sqlserverbase.ddcw.b(Unknown Source)
    at macromedia.jdbc.sqlserverbase.ddcw.a(Unknown Source)

Note that the SQL String is on a single line. When the comment starts, it does not end. Everything after the -- remains as a commented out.

White space management is turned on. Turning it off does not change the behavior. The generated SQL is the same

16
  • 4
    One of my least favourite things about ColdFusion - when you upgrade, things that used to work start to break.
    – Dan Bracuk
    Feb 17, 2016 at 2:57
  • 1
    @JamesAMohler - a) Can you enable debugging in the DSN and check the log file to see the actual sql string being passed to the db? Also, b) check with SQL Profiler to see what statement SQL Server is actually trying to execute and c) Did you check the whitespace management settings Scott mentioned? Because what you posted looks valid to me too, suggesting maybe it is being changed somehow before it hits the db (?) and if so logging/Profiler might help pinpoint what that change is.
    – Leigh
    Feb 17, 2016 at 16:44
  • 1
    Note that the SQL String is on a single line. Hmm... well that would sort of explain the syntax error. As a single line, it is no longer a valid sql statement with the comment breaking it up in the middle. I do not recall if the spy log formats the sql string in any way. Check the SQL Profiler. Is that statement really being executed a single line, or is that just how it appears in the spy log?
    – Leigh
    Feb 17, 2016 at 20:20
  • 1
    I submitted a bug: bugbase.adobe.com/index.cfm?event=bug&id=4118874 Feb 17, 2016 at 22:31
  • 1
    Bug #4118874 - Subtitle: Keep your grubby mitts off the SQL ;-)
    – Leigh
    Feb 17, 2016 at 22:52

1 Answer 1

1

According to Adobe, adding Update 1 will address this issue

List of issues patched in Update 1: https://helpx.adobe.com/coldfusion/kb/bugs-fixed-coldfusion-2016-update-1.html#main-pars_minitoc

Details of Update 1: https://helpx.adobe.com/coldfusion/kb/coldfusion-2016-update-1.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.