Skip navigation
Jeremy Tan
Currently Being Moderated

Weird transaction issue with implicit struct (and possible array)

Feb 24, 2013 3:33 PM

I have the following 2 files.


<cfcomponent  output="false">


          <cffunction name="set" output="true" returntype="void">

                    <cfargument name="text1" type="string" required="true">

                    <cfargument name="something" type="any" required="true">

                    <cfdump var="#arguments#">







          test = {firstName="Bob in line 2"};


          transaction {

     new mycfc().set(Text1:"hello",something:"Bob in text");


     new mycfc().set(Text1:"hello",something:"Bob in text again");

     new mycfc().set(Text1:"hello",something:test);

     new mycfc().set(Text1:"hello",something:{firstName="Bob in line 9"});

     test2 = {firstName="Merry"};

     writeDump(var=test2,label="line 11" );

     new mycfc().set(Text1:"hello",something:{firstName="Jenny"});


     new mycfc().set(Text1:"hello",something:{firstName="Jenny 2"});


          writeDump("i = #i#");




If you run the mycfc.cfm, you will notice 4 weird things here.

1) new mycfc().set(Text1:"hello",something:test); should output "Bob in line 2", but is replace with "Bob in line 9"

2) my dump with label="line 11" is missing.

3) duplication of "Jenny 2", even you remove the writedump, you still get double "Jenny 2".

4) writeDump("i = #i#"); will give you "i = 2", which should be i = 3


This problem only happen when using transaction. It is happen to both CF9 and CF10

  • Currently Being Moderated
    Feb 25, 2013 1:15 AM   in reply to Jeremy Tan

    You shouldn't use the colon to separate argument name=value pairs.  It's undocumented, use = instead

         new mycfc().set(Text1:"hello",something:"Bob in text");

    should be

         new mycfc().set(Text1 = "hello",something = "Bob in text");


    Apart from that I couldn't say for the other strangeness you're experiencing.  I've seen problems using inline structures being passed as arguments, try creating them as variables and passing those instead

    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 5:14 PM   in reply to duncancumming

    The colon _is_ documented and supported in CF10.

    Mark as:
  • Currently Being Moderated
    Feb 28, 2013 12:15 PM   in reply to Jeremy Tan

    I had a look at this, and it's a variation of a bug we (Duncan: you and I) experienced a while back, and that Brad Wood helped me lock down to a decent repro case. I blog about this current example - with links to various bugs and older blog posts - here: ruct-literal-syntax.html


    It's more serious (well: less of an edge-case, anyhow) than this example makes it look.




    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points