Skip to content

Commit 8900c32

Browse files
committed
Fix an issue with array management
1 parent 2e262fb commit 8900c32

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/component.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,15 @@ function addProperties(model, Class, classId) {
769769
return runtimeArr;
770770
} else {
771771
if (Array.isArray(position)) { // we replace the collection
772-
if (_isValidCollection(position, propertyType[0])) {
772+
if (_isValidCollection(position, propertyType === 'array' ? 'any' : propertyType[0])) {
773773
search = $db[classId].find({
774774
'_id': this.id()
775775
});
776776
if (search.length) {
777777

778778
component = search[0];
779-
realVal = _getRealCollection(position, propertyType[0]);
780-
779+
realVal = _getRealCollection(position, propertyType === 'array' ? 'any' : propertyType[0]);
780+
781781
$workflow.state({
782782
'component': this.id(),
783783
'state': propertyName,
@@ -802,7 +802,7 @@ function addProperties(model, Class, classId) {
802802
if (typeof position === 'number') {
803803
val = $db.store[classId][this.id()][propertyName][position];
804804
if (val) {
805-
if ($metamodel.isClassName(propertyType[0])) {
805+
if ($metamodel.isClassName(propertyType === 'array' ? 'array' : propertyType[0])) {
806806
realVal = $helper.getRuntime().require(val);
807807
} else {
808808
realVal = val;
@@ -819,15 +819,15 @@ function addProperties(model, Class, classId) {
819819
$log.readOnlyProperty(this.id(), this.constructor.name, propertyName);
820820
} else {
821821
if (
822-
$metamodel.isValidType(value, propertyType[0]) ||
823-
($metamodel.inheritFrom(value.constructor.name, propertyType[0].replace('@', '')) && $metamodel.isClassName(propertyType[0]))
822+
$metamodel.isValidType(value, propertyType === 'array' ? 'any' : propertyType[0]) ||
823+
($metamodel.inheritFrom(value.constructor.name, propertyType === 'array' ? 'array' : propertyType[0].replace('@', '')) && $metamodel.isClassName(propertyType === 'array' ? 'array' : propertyType[0]))
824824
) {
825825
search = $db[classId].find({
826826
'_id': this.id()
827827
});
828828
if (search.length) {
829829

830-
if ($metamodel.isClassName(propertyType[0])) {
830+
if ($metamodel.isClassName(propertyType === 'array' ? 'array' : propertyType[0])) {
831831
switch (true) {
832832
case typeof value === 'string':
833833
realVal = value;

src/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ function cyclicDependency(name) {
640640
* @param {String} type typeName of the type
641641
*/
642642
function invalidEnumType(value, typeName, type) {
643-
if (type !== typeof value) {
643+
if (typeof type !== 'undefined' && type !== typeof value) {
644644
getLogger().warn("invalid type for enumerated type '" + typeName + "': expected type '" + type + "' instead of type '" + typeof value + "'");
645645
} else {
646646
getLogger().warn("invalid type for enumerated type '" + typeName + "'");

src/metamodel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,11 @@ function isValidType(value, typeName) {
15141514
result = checkCustomSchema(value, typeName);
15151515

15161516
if (!result) {
1517-
$log.invalidEnumType(value, typeName, store.type[typeName].type);
1517+
if (store.type[typeName]) {
1518+
$log.invalidEnumType(value, typeName, store.type[typeName].type);
1519+
} else {
1520+
$log.invalidEnumType(value, typeName);
1521+
}
15181522
}
15191523

15201524
if (result) {

0 commit comments

Comments
 (0)