I’m wondering how makumba is handling uniqueness validation rules between multiple fields, when there are null fields involved.
For instance:
a = not null not empty char…
b = ptr …
unique(a, b)
What’ll happen in the cases where ‘b’ is null. Will this check be done with ‘+null’ or will it be bypassed?
There are two different cases
(1) If the validation rule covers only fields from one MDD, then this will be translated into a unique constraint on the database level, and how that is handled there might be depending on the DB engine used.
In mysql, null values are allowed to be repeated (http://dev.mysql.com/doc/refman/5.1/en/create-table.html)
A UNIQUE index creates a constraint such that all values in the index must be distinct. An error occurs if you try to add a new row with a key value that matches an existing row. For all engines, a UNIQUE index permits multiple NULL values for columns that can contain NULL.
I.e. you can actually have identical records!
You can verify that:
So if applicable, you might want to add a not-null statement to the fields in question.
(2) If the rule covers also fields from other MDDs (e.g. via a ptr field), then this will be checked via a query – if there already exists a record that matches the query, the uniqueness check will complain.
In this case null should be treated as any other value would be; i.e. you should not be able to have two records that have two identical records