NULL value to blank value? No more default mapping

Automatically translated from English

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!

Fabrice Mainguené

• Product Owner •

Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.

After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.