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

Weird transaction issue with implicit struct (and possible array)

New Here ,
Feb 24, 2013 Feb 24, 2013

Copy link to clipboard

Copied

I have the following 2 files.

mycfc.cfc

<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#">

          </cffunction>

</cfcomponent>

mycfc.cfm

<cfscript>

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

          i=1;

          transaction {

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

     i++;

     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"});

     i++;

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

          }

          writeDump("i = #i#");

</cfscript>

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

TOPICS
Advanced techniques

Views

1.9K

Translate

Translate

Report

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
Engaged ,
Feb 25, 2013 Feb 25, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Engaged ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

The colon _is_ documented and supported in CF10.

Votes

Translate

Translate

Report

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
New Here ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Thanks duncancumming.

I just found a workaround for that issue. That is if I don't use the argument name, the problem go away...

<cfscript>

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

          i = 1;

          transaction

          {

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

                    i++;

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

                    new mycfc().set("hello", test);

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

                    test2 = {firstName="Merry"};

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

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

                    i++;

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

          }

          writeDump("i = #i#");

</cfscript>

Votes

Translate

Translate

Report

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 ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

LATEST

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: http://adamcameroncoldfusion.blogspot.co.uk/2013/02/another-serious-struct-literal-syntax.html

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

--

Adam

Votes

Translate

Translate

Report

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
Documentation