kre / Kinetic-Rules-Engine

Source code for KRE
GNU General Public License v2.0
54 stars 8 forks source link

Event Send converts "false" values to "null" #43

Closed JessieAMorris closed 11 years ago

JessieAMorris commented 11 years ago

Attached is a code example that casuses this to happen.

  1. Open up https://squaretag.com/app.html#!/app/a41x188/show
  2. Click on the "Get Variable" link. You should get an alert with the value "1"
  3. Next, click on the "Send Event" link. You should get an alert with the values of the attrs array.
  4. Click on the "Get Variable" link again. This should cause an alert of "WAS NULL" to pop up.

What I expect to happen: Rather than the event attribute test coming through as null, I expect it to come through as the value "false".

ruleset a41x188 {
    meta {
        name "neuAppTemplate"
        description <<
            myCloud appication template
      Copyright 2012 Kynetx, All Rights Reserved
        >>
        author "Jessie"
        logging on

    use module a169x701 alias CloudRain
    }

  global {
    thisRID = meta:rid();
    thisECI = meta:eci();
  }

  // ------------------------------------------------------------------------
    rule test_Selected {
        select when web cloudAppSelected
        pre {
          appMenu = [
              {
          "label"  : "More",
                  "action" : "more"
        }
            ];

          appContent = <<
              Hello, World!

        <a href="#!/app/#{thisRID}/sendEvent">Send Event</a>
        <a href="#!/app/#{thisRID}/getVariable">Get Variable</a>
            >>;
        }
        {
            CloudRain:createLoadPanel("appTemplate", appMenu, appContent);
        }

    fired {
      set ent:test true;
    }
    }

  rule test_sendEvent {
    select when web cloudAppAction action re/sendEvent/
    pre {
      cid = {
        "cid": thisECI
      };

      attrs = {
        "test": false,
        "_rids": "a41x188"
      };
    }
    {
      event:send(cid, "test", "testSendEvent")
        with attrs = attrs;
      alert("Event sent with: " + attrs.encode());
    }
  }

  rule test_sendEventCatcher {
    select when test testSendEvent
    pre {
      test = event:attr("test");

      testFinal = (test.isnull()) => "WAS NULL" | test;
    }
    {
      noop();
    }
    fired {
      set ent:test testFinal;
    }
  }

  rule test_getEntity {
    select when web cloudAppAction action re/getVariable/
    pre {
      entity = ent:test;
    }
    {
      alert(entity);
    }
  }
  // ------------------------------------------------------------------------
  // Beyond here there be dragons :)
  // ------------------------------------------------------------------------
}
windley commented 11 years ago

Fixed in 4660ab7