Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bug with preserveSingleQuotes()

Valorous Hero ,
May 10, 2011 May 10, 2011

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.

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 10, 2011 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 10, 2011 May 10, 2011

Done and done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 10, 2011 May 10, 2011

Which version of CF?

CF8 was a abit flaky with the short-form struct / array notation, which was mostly fixed in CF9.  But only mostly: it still has idiosyncrasies.

What if you used more traditional function-based-code to define your array/structs?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 10, 2011 May 10, 2011
LATEST

Adam Cameron. wrote:

Which version of CF?

CF 9.0.0

Someday they will hopefully apply the updater here!

Adam Cameron. wrote:

What if you used more traditional function-based-code to define your array/structs?

I don't know.  I might give that a try somday, but not right now, 6 minuters before "Pub" time as I beleive you call it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources