lsFusion:属性 NULL 的唯一性限制

huangapple go评论72阅读模式
英文:

lsFusion: Uniqueness restriction to a property NULL

问题

如何将唯一性限制添加到属性,以确保只能输入一个NULL值?
在这种情况下,该限制不适用于id的NULL值。
已验证最新版本4.2和5.0。

以下是文档中的示例代码:

CLASS Book 'Book;
id 'Number' = DATA INTEGER (Book);
book 'Book' (INTEGER i) = GROUP AGGR Book b BY id(b);
英文:

Can you tell me how to add a uniqueness restriction to a property so that only one NULL value can be entered?
In this case, the restriction does not work for NULL values of id.
Checked with the latest versions 4.2 and 5.0.

Here is a sample code from the documentation:

CLASS Book 'Book;
id 'Number' = DATA INTEGER (Book);
book 'Book' (INTEGER i) = GROUP AGGR Book b BY id(b);

答案1

得分: 2

以下是您要翻译的内容:

对于任何类型的 GROUP 运算符,如果 BY 子句中的至少一个值为 NULL,结果始终为 NULL。因此,GROUP 运算符 AGGR 创建的标准限制将不考虑空的 id 值。

在这种情况下,要检查多个 NULL 值,您必须创建一个单独的 CONSTRAINT

CONSTRAINT (GROUP SUM 1 IF b IS Book AND NOT id(b)) > 1
    MESSAGE '不允许多个空值';
英文:

For any kind of GROUP operator, the result is always NULL if at least one of the values of the BY clause is NULL. For this reason, standard restriction created by GROUP operator AGGR will not consider empty id values.

To check for multiple NULL values in this case you have to make a separate CONSTRAINT :

CONSTRAINT (GROUP SUM 1 IF b IS Book AND NOT id(b)) > 1
    MESSAGE 'Multiple empty values are not allowed';

huangapple
  • 本文由 发表于 2023年4月20日 07:03:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76059414.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定