Skip to content

JSSDK query with constant containedIn / containsAll fails with *bad $in value* #4996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RaschidJFR opened this issue Aug 20, 2018 · 4 comments

Comments

@RaschidJFR
Copy link
Contributor

Issue Description

Methods for querying array values Query.containedIn() and Query.containsAll() don't work properly in JSDK, they fail with 101: bad $in value.

Steps to reproduce

Make a query like this:

let query = new Parse.Query("AnyClass");
query.containedIn('someArrayField', someValue);
query.find()
    .then(() => console.log('The query was successfull'))
    .catch(error => console.error('The query failed: ', error.message));

Expected /Actual Results

The query should return any object AnyClass containing someValue in its array field someArrayField but instead the request will fail with 400 (Bad Request) error returning Parse Error 101 with the message bad $in value.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.7.1
    • Operating System: Win10
    • Hardware: i5 6200U, 6GB RAM
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
  • Database

    • MongoDB version: MongoDB Community Edition 4.0.1
    • Storage engine: -
    • Hardware: i5 6200U, 6GB RAM
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Localhost

Logs/Trace

Server Log:

error: Error generating response. ParseError { code: 107, message: 'bad $in value' } code=107, message=bad $in value

These are the request headers/params copied from Chrome console:

Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en,es;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 323
Content-Type: text/plain
Host: localhost:1337
Origin: http://localhost:8100
Pragma: no-cache
Referer: http://localhost:8100/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

{
   where:{
      visibleTo:{
         $in:3
      }
   },
   order: "order",
   _method: "GET",
   _ApplicationId: "1xNOHTRrDv1ioSwcfIZT1xO4tqyEQA9qz4oM3lhg",
   _ClientVersion: "js1.11.1"   _InstallationId:"4ecc3512-9bf9-ab82-74ca-989833ef8cad",
   _JavaScriptKey: "<removed>",
   _SessionToken: "<removed>",
}
@flovilmart
Copy link
Contributor

According to the docs; you should pass an array, and not a single value.

https://docs.parseplatform.org/js/guide/#query-constraints

@RaschidJFR
Copy link
Contributor Author

Ok, that easy... Actually I was reading it from the API Reference, which is not as clear as the Guide.
Tnx @flovilmart .

@flovilmart
Copy link
Contributor

I believe the API reference is indeed quite clear

containedIn(key, values) → {Parse.Query}

(values is with an s)

and just below:

values | Array | The values that will match.

I'm not sure what's not clear in that

@RaschidJFR
Copy link
Contributor Author

Boom! You're totally right... how stupid of me >_<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants