Added array support for pointer-permissions (#5921)

* added array support for pointer permissions

* added tests for array support for pointer permissions

* Postgres fix

* simplify PG, no idea why this works
This commit is contained in:
Dobbias Nan
2019-08-16 06:55:12 +02:00
committed by Diamond Lewis
parent 4f8da12674
commit 0fa315fc5b
4 changed files with 1920 additions and 927 deletions

View File

@@ -268,7 +268,7 @@ const buildWhereClause = ({ schema, query, index }): WhereClause => {
const initialPatternsLength = patterns.length;
const fieldValue = query[fieldName];
// nothingin the schema, it's gonna blow up
// nothing in the schema, it's gonna blow up
if (!schema.fields[fieldName]) {
// as it won't exist
if (fieldValue && fieldValue.$exists === false) {
@@ -498,6 +498,12 @@ const buildWhereClause = ({ schema, query, index }): WhereClause => {
}
values.push(fieldName, JSON.stringify(fieldValue.$all));
index += 2;
} else if (Array.isArray(fieldValue.$all)) {
if (fieldValue.$all.length === 1) {
patterns.push(`$${index}:name = $${index + 1}`);
values.push(fieldName, fieldValue.$all[0].objectId);
index += 2;
}
}
if (typeof fieldValue.$exists !== 'undefined') {