Skip to main content
ilssac
Inspiring
May 10, 2011
Question

Bug with preserveSingleQuotes()

  • May 10, 2011
  • 1 reply
  • 1267 views

OR is it just some really strange 'feature'.

IS it just me or should not both of these work?

WORKING CODE

<cfset reports = [
     {name="Reneawal Date before Issue Date",sql="RenewDate < IssueDate"},
     {name="Expiration Date before Renewal Date",sql="ExpirationDate < RenewDate"},
     {name="Expiration Date before Issue Date",sql="ExpirationDate < IssueDate"},
     {name="Not Fly Anomolies",sql=""},
     {name="Expiration Date NOT December 31st",sql="DAY(ExpirationDate) != 31 OR MONTH(ExpirationDate) != 12"}
     ]>

<cfset variables.sql = reports[1].sql>

<cfquery ...>
    SELECT aField, bField, cField
    FROM aTable
    WHERE #preserveSingleQuotes(variables.sql)#
</cfquery>

FAILING CODE

<cfset reports = [
     {name="Reneawal Date before Issue Date",sql="RenewDate < IssueDate"},
     {name="Expiration Date before Renewal Date",sql="ExpirationDate < RenewDate"},
     {name="Expiration Date before Issue Date",sql="ExpirationDate < IssueDate"},
     {name="Not Fly Anomolies",sql=""},
     {name="Expiration Date NOT December 31st",sql="DAY(ExpirationDate) != 31 OR MONTH(ExpirationDate) != 12"}
     ]>

<cfquery ...>

    SELECT aField, bField, cField
    FROM aTable

    WHERE #preserveSingleQuotes(reports[1].sql)#
</cfquery>

Complex constructs are not supported with function

preserveSingleQuotes

Use simple variable instead

Message was edited by: ilssac  Ok, after some thought, and a closer reading of the error message, maybe not a true bug or feature, but it still strikes me as a rather strange limitation requirement of the function.

    This topic has been closed for replies.

    1 reply

    Community Expert
    May 10, 2011

    Yes, they should both work. But there are a few places where variables are not interchangeable as you'd expect them to be. I'd file a bug report and move on.

    Dave Watts, CTO, Fig Leaf Software

    http://www.figleaf.com/

    http://training.figleaf.com/

    Dave Watts, Eidolon LLC
    ilssac
    ilssacAuthor
    Inspiring
    May 10, 2011

    Done and done.