Skip to content

Nested $OR queries BREAK with ERROR 105 - Invalid key name: 0 #2221

Closed
@JOscarEduardo

Description

@JOscarEduardo

Issue Description

A simple query with nested $ORs is not working. Instead, it returns ERROR 105 - Invalid key name: 0

Steps to reproduce

This WORKS - Parse Hosted Server:
https://api.parse.com/1/classes/AnyCollection?where={"$or":[{"$or":[{"x":1},{"x":2}]},{"$or":[{"x":3},{"x":4}]}]}

This BREAKS - Local Parse Server:
http://localhost:1337/parse/classes/AnyCollection?where={"$or":[{"$or":[{"x":1},{"x":2}]},{"$or":[{"x":3},{"x":4}]}]}
WIth ERROR{"code":105,"message":"Invalid key name: 0"}

Expected Results

The query must run with no errors and returns 0 or more values, depending on data in the database. This is happening correctly in the Parse Hosted server. However in my LOCAL Parse Server, it is firing an error.

Actual Outcome

An error happens when the query runs, even in a COMPLETELY EMPTY Application:

CLIENT SIDE: {"code":105,"message":"Invalid key name: 0"}
SERVER SIDE:throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, 'Invalid key name: ' + key);
(DatabaseController.js:99)

Environment Setup

  • Server
    • parse-server version: 2.2.15
    • Operating System: Windows 8.1
    • Hardware: Intel i7, 16Gb RAM
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [FILL THIS OUT]
  • Database
    • MongoDB version: 3.0.9
    • Storage engine: Windows 8.1
    • Hardware: Intel i7, 16Gb RAM
    • Localhost or remote server? LOCAL HOSTED

Logs/Trace

I did not find any useful information with VERBOSE. However, after a few hours debbuging I noticed that when the function:
_this10.reduceInRelation(className, query, schemaController);
is called, it transforms the query from
{"$or":[{"$or":[{"x":1},{"x":2}]},{"$or":[{"x":3},{"x":4}]}]}
to:
{"$or":[[null,null],[null,null]]}

Then when validateQuery(query) is called for each of the $or's, it receives [null,null] as arguments and then breaks.

I could not understand why this is happening, but I guess this is the source of the problem.

THANKS A LOT!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions