4 Replies Latest reply: May 10, 2011 4:48 PM by ilssac RSS

    Bug with preserveSingleQuotes()

    ilssac Community Member

      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.