Akayy
May 18, 2020, 3:56pm
1
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 ? "NOT NULL" : "NULL""></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="'"something"'"></dmx-value>
<dmx-value id="var_text_is_null" dmx-bind:value="var_text.value ? "NOT NULL" : "NULL""></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 ? "NOT NULL" : "NULL""></dmx-value>
<p>Var_boolean_is_null - {{var_boolean_is_null.value}}</p>
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
Akayy
May 18, 2020, 4:59pm
4
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 != "null") ? "NOT NULL" : "NULL")"></dmx-value>
Akayy
May 18, 2020, 5:39pm
6
@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 != "null" ? "NOT NULL" : "NULL")"></dmx-value>
<p>Var_number2_is_null - {{var_number2_is_null.value}}</p>
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")
Akayy
May 19, 2020, 11:45am
8
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?
Akayy
May 19, 2020, 1:28pm
9
Additional details on how this expression was built…
Akayy
May 19, 2020, 1:33pm
10
When extending the above expression with another ternary operation, gives a parse error … like below, probably the underlying issue is the same…