fix: Parse.Query.containedIn and matchesQuery do not work with nested objects (#9738)
This commit is contained in:
@@ -327,7 +327,7 @@ function transformQueryKeyValue(className, key, value, schema, count = false) {
|
||||
}
|
||||
|
||||
// Handle query constraints
|
||||
const transformedConstraint = transformConstraint(value, field, count);
|
||||
const transformedConstraint = transformConstraint(value, field, key, count);
|
||||
if (transformedConstraint !== CannotTransform) {
|
||||
if (transformedConstraint.$text) {
|
||||
return { key: '$text', value: transformedConstraint.$text };
|
||||
@@ -651,12 +651,15 @@ function transformTopLevelAtom(atom, field) {
|
||||
// If it is not a valid constraint but it could be a valid something
|
||||
// else, return CannotTransform.
|
||||
// inArray is whether this is an array field.
|
||||
function transformConstraint(constraint, field, count = false) {
|
||||
function transformConstraint(constraint, field, queryKey, count = false) {
|
||||
const inArray = field && field.type && field.type === 'Array';
|
||||
// Check wether the given key has `.`
|
||||
const isNestedKey = queryKey.indexOf('.') > -1;
|
||||
if (typeof constraint !== 'object' || !constraint) {
|
||||
return CannotTransform;
|
||||
}
|
||||
const transformFunction = inArray ? transformInteriorAtom : transformTopLevelAtom;
|
||||
// For inArray or nested key, we need to transform the interior atom
|
||||
const transformFunction = (inArray || isNestedKey) ? transformInteriorAtom : transformTopLevelAtom;
|
||||
const transformer = atom => {
|
||||
const result = transformFunction(atom, field);
|
||||
if (result === CannotTransform) {
|
||||
|
||||
Reference in New Issue
Block a user