When you create a new field in your database, 4D allows you to choose to map NULL value to blank values or not. Starting from 4D v19 R4, in new projects, 4D will no longer by default map the NULL value to an empty value.
Quick history recap: older versions of 4D (before 4D v11 was introduced) did not support NULL. Not in the database nor in the language.
Starting with 4D v11, databases supported NULL, as well as 4D’s SQL language, but not the 4D language. For this precise reason, by default, the option “map NULL value to blank values” was pre-selected for newly created fields. It made coding with 4D’s language way easier.
Back to the present day, and with ORDA, it is a different story. ORDA is fully aware of NULL and using the concept of NULL opens a lot of possibilities in your code.
NULL is used to mark absent data. Even if mapping NULL with an empty value can seem logical, it is really not the same. For example, if a user enters a 0 or never entered anything, it might be a major difference for you! NULL tells you that no value was ever entered.
ORDA is designed to work with NULL values. For example the .count() function returns the number of entities in the entity selection with a non-null value. With ORDA it is a much better practice to keep the support of NULL, and thus avoid mapping it to an empty value.
For example, if you need to count how many of your clients have entered a mobile phone number in their description, if the “mobile” field of your table support Null value, just write:
$count:=ds.Users.all().count("mobile")
Whenever you need to map a NULL value to a blank value, you still can use the option Map NULL values to blank values in the field properties:
As ORDA became the standard way to work with 4D, it is now time to change the default value for this option. Starting a project with 4D v19 R4, this option is not set by default anymore for newly created fields – but of course, you can still enable it if needed!