null ("M" Technical Reference)
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
null is a distinguished value of type Null that serves as a place holder for some other value that is not known. The value null can be added to the value space of any non-collection type by using the postfix operator ?. The result is a nullable type, very similar to the nullable types in the T-SQL language. The following example makes true assertions about some nullable types.
null in Integer32?
null in Text?
!(null in Text)
Arithmetic operations on a null operand return null as seen in the following code.
1 + null == null
null * 3 == null
Logical operators, conditional, and constraints require non-nullable operands.
A null coalescing expression of the form a ?? b
requires a
to be nullable. If a
is not null, the result of a ?? b is a; otherwise, the result is b. The operation evaluates b
only if a
is null. b
must be of the same type a
without the value null.
Syntax
null
By setting a value equal to this literal, you are specifying that its value is unknown.
Examples
The following Person
entity initializes the MiddleName
field to null.
module Contacts
{
type Person
{
FirstName : Text;
MiddleName : Text? = null;
LastName : Text;
}
}
The values in the following extent conform to the Person
type.
People : Person*;
People
{
{FirstName => "Joe", LastName => "Smith"},
{FirstName => "Jim", MiddleName => null, LastName => "Smith"},
{FirstName => "John", MiddleName => "Bob", LastName => "Smith"}
}