@@ -168,12 +168,12 @@ function transformQueryKeyValue(schema, className, key, value, { validate } = {}
168
168
if ( ! ( value instanceof Array ) ) {
169
169
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'bad $or format - use an array value' ) ;
170
170
}
171
- return { key : '$or' , value : value . map ( subQuery => transformWhere ( schema , className , subQuery , parseFormatSchema ) ) } ;
171
+ return { key : '$or' , value : value . map ( subQuery => transformWhere ( schema , className , subQuery , { } , parseFormatSchema ) ) } ;
172
172
case '$and' :
173
173
if ( ! ( value instanceof Array ) ) {
174
174
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'bad $and format - use an array value' ) ;
175
175
}
176
- return { key : '$and' , value : value . map ( subQuery => transformWhere ( schema , className , subQuery , parseFormatSchema ) ) } ;
176
+ return { key : '$and' , value : value . map ( subQuery => transformWhere ( schema , className , subQuery , { } , parseFormatSchema ) ) } ;
177
177
default :
178
178
// Other auth data
179
179
const authDataMatch = key . match ( / ^ a u t h D a t a \. ( [ a - z A - Z 0 - 9 _ ] + ) \. i d $ / ) ;
@@ -187,18 +187,19 @@ function transformQueryKeyValue(schema, className, key, value, { validate } = {}
187
187
}
188
188
}
189
189
190
- let expected = undefined ;
191
- if ( schema && schema . getExpectedType ) {
192
- expected = schema . getExpectedType ( className , key ) ;
193
- }
194
- if ( ( expected && expected . type == 'Pointer' ) ||
195
- ( ! expected && value && value . __type == 'Pointer' ) ) {
196
- key = '_p_' + key ;
197
- }
198
190
const expectedTypeIsArray =
199
191
parseFormatSchema &&
200
192
parseFormatSchema . fields [ key ] &&
201
- parseFormatSchema . fields [ key ] . type === 'Array'
193
+ parseFormatSchema . fields [ key ] . type === 'Array' ;
194
+
195
+ const expectedTypeIsPointer =
196
+ parseFormatSchema &&
197
+ parseFormatSchema . fields [ key ] &&
198
+ parseFormatSchema . fields [ key ] . type === 'Pointer' ;
199
+
200
+ if ( expectedTypeIsPointer || ! parseFormatSchema && value && value . __type === 'Pointer' ) {
201
+ key = '_p_' + key ;
202
+ }
202
203
203
204
// Handle query constraints
204
205
if ( transformConstraint ( value , expectedTypeIsArray ) !== CannotTransform ) {
0 commit comments