Null check on doesn't works on numbers

Wappler Version : 2.9.0
Operating System : Mac OSX Catalina v10.15.3
Experimental: Switched on

Null check doesn’t work on numbers (from any component - var, serverconnect, datastore etc).

<dmx-value id="var_number" dmx-bind:value="0"></dmx-value>
<dmx-value id="var_number_is_null" dmx-bind:value="var_number.value ? &quot;NOT NULL&quot; : &quot;NULL&quot;"></dmx-value>
<p >Var_number_is_null - {{var_number_is_null.value}}</p>

(works fine on text & boolean)

<dmx-value id="var_text" dmx-bind:value="'&quot;something&quot;'"></dmx-value>
<dmx-value id="var_text_is_null" dmx-bind:value="var_text.value ? &quot;NOT NULL&quot; : &quot;NULL&quot;"></dmx-value>
<p>Var_text_is_null - {{var_text_is_null.value}}</p>

<dmx-value id="var_boolean" dmx-bind:value="true"></dmx-value>
<dmx-value id="var_boolean_is_null" dmx-bind:value="var_boolean.value ? &quot;NOT NULL&quot; : &quot;NULL&quot;"></dmx-value>
<p>Var_boolean_is_null - {{var_boolean_is_null.value}}</p>

image

You are not checking NULL, your check will also fail with an empty string and a boolean false.

Correct check is:

var_number.value != null ? 'NOT NULL' : 'NULL'
1 Like

Thanks @patrick, good to learn how null is checked…

But, when I build my expression visually, do I set the type of null to “text” or something else?

When I leave it text, the expression gets build with double-quotes around null, just want to make sure if it will work fine with the double quotes in all cases.

<dmx-value id="var_number_is_null" 
dmx-bind:value="(var_number.value != &quot;null&quot;) ? &quot;NOT NULL&quot; : &quot;NULL&quot;)"></dmx-value>

@Teodor, this is still a bug.

Even after I followed @patrick’s clarification, when I check on a variable that’s uninitialised, the null check expression (built visually) fails. sample code below.

<dmx-value id="var_number2"></dmx-value>
<dmx-value id="var_number2_is_null" dmx-bind:value="(var_number2.value != &quot;null&quot; ? &quot;NOT NULL&quot; : &quot;NULL&quot;)"></dmx-value>
<p>Var_number2_is_null - {{var_number2_is_null.value}}</p>

image

Your expression is (var_number2.value != "null" ? "NOT NULL" : "NULL"), you checking with a string, not a null value. Remove the quotes arround null.

(var_number2.value != null ? "NOT NULL" : "NULL")

Thanks @patrick, Im able to edit it in code view, yes…

but how do I do it visually in the data picker? The double quotes gets automatically added around null…

If you refer to the screenshot above, you will understand where the blocker is… Is this a limitation of the expression builder?

Additional details on how this expression was built…

When extending the above expression with another ternary operation, gives a parse error… like below, probably the underlying issue is the same…