Skip to content

Commit

Permalink
Merge a5b30d3 into 3ff1f51
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishiking committed Mar 9, 2021
2 parents 3ff1f51 + a5b30d3 commit e408c19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ export namespace entity {
if (
firstPathPartIsArray &&
// check also if the property in question is actually an array value.
entity.properties![firstPathPart] &&
entity.properties![firstPathPart].arrayValue &&
// check if wildcard is not applied
!hasWildCard
Expand All @@ -850,15 +851,17 @@ export namespace entity {
}
});
} else if (firstPathPartIsArray && hasWildCard && remainderPath === '*') {
const array = entity.properties![firstPathPart].arrayValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
array.values.forEach((value: any) => {
if (value.entityValue) {
excludePathFromEntity(value.entityValue, '.*');
} else {
excludePathFromEntity(value, '');
}
});
if (entity.properties![firstPathPart]) {
const array = entity.properties![firstPathPart].arrayValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
array.values.forEach((value: any) => {
if (value.entityValue) {
excludePathFromEntity(value.entityValue, '.*');
} else {
excludePathFromEntity(value, '');
}
});
}
} else if (firstPathPartIsEntity) {
if (firstPathPart === '') {
Object.keys(entity.properties!).forEach(path => {
Expand All @@ -869,17 +872,19 @@ export namespace entity {
});
} else {
if (hasWildCard && remainderPath === '*') {
const parentEntity = entity.properties![firstPathPart].entityValue;

if (parentEntity) {
Object.keys(parentEntity.properties).forEach(path => {
const newPath = parentEntity.properties[path].arrayValue
? path + '[].*'
: path + '.*';
excludePathFromEntity(parentEntity, newPath);
});
} else {
excludePathFromEntity(entity, firstPathPart);
if (entity.properties![firstPathPart]) {
const parentEntity = entity.properties![firstPathPart]
.entityValue;
if (parentEntity) {
Object.keys(parentEntity.properties).forEach(path => {
const newPath = parentEntity.properties[path].arrayValue
? path + '[].*'
: path + '.*';
excludePathFromEntity(parentEntity, newPath);
});
} else {
excludePathFromEntity(entity, firstPathPart);
}
}
} else {
const parentEntity = entity.properties![firstPathPart].entityValue;
Expand Down
2 changes: 2 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,8 @@ describe('Datastore', () => {
'metadata.otherProperty',
'metadata.obj.*',
'metadata.longStringArray[].*',
'undefinedData.*',
'undefinedArray[].*',
],
},
assert.ifError
Expand Down

0 comments on commit e408c19

Please sign in to comment.