OrientDB ALTER PROPERTY会影响超类和所有其他后代类吗?

时间:2016-05-05 12:13:28

标签: orientdb

我正在尝试使用2.1.16进行继承,并注意到在子类上使用ALTER PROPERTY来改变继承属性时,会更改超类和该超类的所有后代的模式。在下面的示例中,B扩展A. C扩展A. B更改从A继承的属性的强制/非空。模式更改影响A,B和C.

这是否是改变继承属性的预期行为(至少就强制/非空无关而言)?如果是这样,是否有一种方法可以使子类的限制更多/更少,或者有意的是,所有继承的子类中的类模式是否相同?

无论A是否为抽象,下面的结果都是相同的。

CREATE CLASS A Extends V ABSTRACT;
CREATE PROPERTY A.Name STRING;
CREATE PROPERTY A.Description STRING;

CREATE CLASS B Extends A ;
ALTER PROPERTY B.Name MANDATORY TRUE;
ALTER PROPERTY B.Name NOTNULL TRUE;

CREATE CLASS C Extends A ;

CREATE VERTEX C CONTENT { "Description": "Hello" }; 

即使C扩展A而不是B:

,也会产生以下消息
The field 'A.Name' is mandatory, but not found on record: C{Description:Hello}

对于所有三个Name属性,类属性显示为必需/ notnull为真:

CLASS 'A'...

PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 NAME                          | TYPE        | LINKED TYPE/CLASS             | MANDATORY | READONLY | NOT NULL |    MIN    |    MAX    | COLLATE  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 Name                          | STRING      | null                          | true      | false    | true     |           |           | default  |
 Description                   | STRING      | null                          | false     | false    | false    |           |           | default  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
orientdb {db=AdvRepos}> info class B

CLASS 'B'...

PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 NAME                          | TYPE        | LINKED TYPE/CLASS             | MANDATORY | READONLY | NOT NULL |    MIN    |    MAX    | COLLATE  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 Name                          | STRING      | null                          | true      | false    | true     |           |           | default  |
 Description                   | STRING      | null                          | false     | false    | false    |           |           | default  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
orientdb {db=AdvRepos}> info class C

CLASS 'C'...


PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 NAME                          | TYPE        | LINKED TYPE/CLASS             | MANDATORY | READONLY | NOT NULL |    MIN    |    MAX    | COLLATE  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
 Name                          | STRING      | null                          | true      | false    | true     |           |           | default  |
 Description                   | STRING      | null                          | false     | false    | false    |           |           | default  |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+

0 个答案:

没有答案