Details

    • Type: Feature Request Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.1.0.000
    • Labels:
      None
    • Similar Issues:
      Show 10 results 

      Description

      ATM CFML is only supporting null halfway and this can be a pain in the ass.
      you can store null in a struct/array/query and in some situation is does return the value in other it throws a error, in addition there is no literal for null.

      Example code that should work:
      <cfset y=null>
      <cf_valueEquals left="#isNull(variables.y)#" right="#true#">
      <cf_valueEquals left="#variables.y == null#" right="#true#">
      <cf_valueEquals left="#variables['y'] == null#" right="#true#">
      <cf_valueEquals left="#y == null#" right="#true#">
      <cf_valueEquals left="#isDefined('variables.y')#" right="#true#">
      <cf_valueEquals left="#structKeyExists(variables,'y')#" right="#true#">

        Gliffy Diagrams

          Activity

          Hide
          Michael Offner added a comment -

          testcase attached

          Show
          Michael Offner added a comment - testcase attached
          Show
          Michael Offner added a comment - https://github.com/getrailo/railo/commit/17788fccddffead3597d13504c6f888433331e90
          Hide
          Michael Offner added a comment -

          this setting will change the following behavior in the language:
          1.null can no longer be used as variable, the following throws a exception
          <cfset null=1>

          2. the function structKeyExists return "true" in the following example:
          x=null;
          dump(structKeyExists(variables,'x'));

          "null" that is set in this case with the key "x" is a valid value.
          it is also the much better behavior in general, then with the default behavior this function return false, even the function structKeyList is listening this key?! was a question last week in the mailing list btw

          2. the function isDefined return "true" in the following example:
          x=null;
          dump(isDefined('x'));

          3. "empty" query (Resultset) cell do not return a empty string, the return null:
          Example:
          qry=query(firstname:['Urs','Susi'],age:[20,null]);
          dump(qry.age[2]);

          sound like a big problem for compatibility, but in CFML (Railo and ACF) "null" can be casted to a string without a problem, so the following
          dump("wor"&null&"ks");
          outputs "works"

          4. argument scope
          the argument scope default behavior is strange, take this example:
          function test(a){
          writedump(arguments['a']);
          writedump(arguments.a);
          writedump(a);
          }
          test();

          in ACF ...
          the first dump outputs null, the second dump throws a exception with the message "Element A is undefined in ARGUMENTS" and the third throws a exception with the message "Variable A is undefined"

          in Railo ...
          we have not followed the behavior from ACF, then the language should act the same way, independent of the syntax you access a variable, for us this is simply a bug in ACF.
          to be as much as compatible to ACF we choose the following solution:
          Railo return "null" in any case, so the same behavior for every call as ACF has for "writedump(arguments['a']);"

          BUT when you enable "full null support"
          it throws a exception like ACF does with "arguments.a", because null is a valid value we do not use as default value for arguments, but of couse you could still do
          function test(a=null){}

          5. cfparam accept null as valid value
          so the following does not throws a exception
          <cfset z=null>
          <cfparam name="z">
          i fact this is not working atm, but this is the expected behavior, so i have open a ticket for this
          https://issues.jboss.org/browse/RAILO-2351

          Show
          Michael Offner added a comment - this setting will change the following behavior in the language: 1.null can no longer be used as variable, the following throws a exception <cfset null=1> 2. the function structKeyExists return "true" in the following example: x=null; dump(structKeyExists(variables,'x')); "null" that is set in this case with the key "x" is a valid value. it is also the much better behavior in general, then with the default behavior this function return false, even the function structKeyList is listening this key?! was a question last week in the mailing list btw 2. the function isDefined return "true" in the following example: x=null; dump(isDefined('x')); 3. "empty" query (Resultset) cell do not return a empty string, the return null: Example: qry=query(firstname: ['Urs','Susi'] ,age: [20,null] ); dump(qry.age [2] ); sound like a big problem for compatibility, but in CFML (Railo and ACF) "null" can be casted to a string without a problem, so the following dump("wor"&null&"ks"); outputs "works" 4. argument scope the argument scope default behavior is strange, take this example: function test(a){ writedump(arguments ['a'] ); writedump(arguments.a); writedump(a); } test(); in ACF ... the first dump outputs null, the second dump throws a exception with the message "Element A is undefined in ARGUMENTS" and the third throws a exception with the message "Variable A is undefined" in Railo ... we have not followed the behavior from ACF, then the language should act the same way, independent of the syntax you access a variable, for us this is simply a bug in ACF. to be as much as compatible to ACF we choose the following solution: Railo return "null" in any case, so the same behavior for every call as ACF has for "writedump(arguments ['a'] );" BUT when you enable "full null support" it throws a exception like ACF does with "arguments.a", because null is a valid value we do not use as default value for arguments, but of couse you could still do function test(a=null){} 5. cfparam accept null as valid value so the following does not throws a exception <cfset z=null> <cfparam name="z"> i fact this is not working atm, but this is the expected behavior, so i have open a ticket for this https://issues.jboss.org/browse/RAILO-2351
          Hide
          Jeroen Knoef added a comment -

          Actually, function test(a = null) {} doesn't give arguments.a = null.

          function test(a = null) {
          	dump(arguments.a)
          }
           
          test()

          Error: key [A] doesn't exist in argument scope. existing keys are []

          Show
          Jeroen Knoef added a comment - Actually, function test(a = null) {} doesn't give arguments.a = null. function test(a = null) { dump(arguments.a) }   test() Error: key [A] doesn't exist in argument scope. existing keys are []
          Hide
          Michael Offner added a comment -

          @Jeroen
          added a new ticket for the issue
          https://issues.jboss.org/browse/RAILO-2403

          Show
          Michael Offner added a comment - @Jeroen added a new ticket for the issue https://issues.jboss.org/browse/RAILO-2403

            People

            • Assignee:
              Michael Offner
              Reporter:
              Michael Offner
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development