Skip to content

is Parse Query Constraints not supported ?  #211

Description

@anwar-al-jahwari

Hello ,

I have successfully migrate the database to mongodb and i uploaded parse server to google app engine , i tried to query a class called Category
it worked.However , when i try to do some Constrains like where equal to it didn't work.

the rest api ,shows the same result with or without constrains

screen shot 2016-02-03 at 5 03 57 pm

screen shot 2016-02-03 at 5 03 41 pm

in addition i have tried the same thing in android sdks and it didn't work when i put constrains only it works without the constrains.

Activity

  1. armenkh commented on Feb 3, 2016

    @armenkh

    I have similar problems.
    Query with constrains returns all the elements of the Item, I reported in the for mum also:
    https://groups.google.com/forum/#!topic/parse-developers/rPxdWUNSagI

    Doesn't properly work with Android SDK eather:
    http://stackoverflow.com/questions/35154414/parse-getinbackground-throws-invalidkeyname-exception

  2. rmistry75 commented on Feb 4, 2016

    @rmistry75

    Same problem here. Whenever I try to query (via REST API) using a "where" clause, the clause is ignored and instead I get ALL items of that class.

  3. gfosco commented on Feb 5, 2016

    @gfosco
    Contributor

    Ok, this is not supposed to be the case, obviously. Must be some difference from the various test scenarios we have. Will look at it very soon.

  4. added
    type:bugImpaired feature or lacking behavior that is likely assumed
    on Feb 5, 2016
  5. bodhaguru commented on Feb 10, 2016

    @bodhaguru

    Same problem for me too - when using REST API. It is giving error on line 83 in node_modules/parse-server/node_modules/body-parser/lib/types/json.js file - saying "Unexpected token ....". It is expecting only "{" or "[" there, whereas what is getting passed is "w" or "u" depending upon the query.

  6. petek157 commented on Feb 18, 2016

    @petek157

    I am having this issue as well. I see there are a number of "issues" regarding this topic but it doesn't seem as though any of them have resolved. I have tried using REST, PHP and JS and its seems like none are adhering to constraints. I apologize that I can't elaborate like others as I used Parse because Im not as advanced in programming to build this out my self. My issue seem like above that no matter what constraints I put on a query I get all objects in that class.

    <?php
    
    use Parse\ParseClient;
    use Parse\ParseCloud;
    use Parse\ParseObject;
    use Parse\ParseQuery;
    use Parse\ParseFile;
    use Parse\ParseUser;
    ParseClient::initialize('APPID', 'REST', 'MASTER');
    ParseClient::setServerURL('http://URL:1377/parse');
    
    $query = new ParseQuery("Product");
    
    $query->equalTo("length", 9);
    $object = $query->first();
    echo $object->getObjectId();
    ?>
    

    //Returns wrong objectId
    //Assuming its just the "first" object returned

    Parse.initialize("APPID", "JSKEY");
        Parse.serverURL = 'http://URL:1377/parse';
    
        var Product = Parse.Object.extend("Product");
        var query = new Parse.Query(Product);
        //query.equalTo("length", 9);
        query.find({
          success: function(product) {
            // The object was retrieved successfully.
            console.log("Color: " + product[0].get("visualColor"));
            console.log("ID: " + product[0].id);
          },
          error: function(object, error) {
            // The object was not retrieved successfully.
            // error is a Parse.Error with an error code and message.
          }
        });
    

    Logs blank and the incorrect id
    again assuming its just the first object returned.
    checking the count 5 objects are returned which is all of them and only 1 has the length of 9

    curl -X GET \
    >   -H "X-Parse-Application-Id: APPID" \
    >   -H "X-Parse-Rest-API-Key: RESTKEY" \
    >   -G \
    >   --data-urlencode 'where={"objectId":"kVzk5HYB9k"}' \
    >   http://URL:1377/parse/classes/Product
    

    Curl returns list of all objects

  7. nlutsenko commented on Feb 21, 2016

    @nlutsenko
    Contributor

    Looks like we don't handle url queries in Classes to be passed as non-body parameters, this is definetly a bug, but for now as a workaround - use JSON body with method: GET inside of it.

  8. rmistry75 commented on Feb 22, 2016

    @rmistry75

    Hi, I'm not sure what the "workaround - use JSON body with method: GET inside of it." means. Can you please show us how to implement the workaround with an example. Perhaps you can show us how to fix the example listed above:

    curl -X GET \

    -H "X-Parse-Application-Id: APPID"
    -H "X-Parse-Rest-API-Key: RESTKEY"
    -G
    --data-urlencode 'where={"objectId":"kVzk5HYB9k"}'
    http://URL:1377/parse/classes/Product

    What would the workaround solution look like for this curl request?

    Thanks!

  9. marcinwalus commented on Dec 1, 2016

    @marcinwalus

    Hi!
    I just migrated app from Parse.com to Azure Managed services. I have everything working correctly (parse dashboard, etc.). Except this issue with "Query Constraints".
    From my Mac app when I ask for specific object in class with given "objectId" I'm getting all objects in class in return and not one specific. In Api Console in my parse dashboard I'm getting specific object correctly.
    @nlutsenko Is this issue fixed?

  10. flovilmart commented on Dec 1, 2016

    @flovilmart
    Contributor

    @marcinwalus can you run parse server with VERBOSE=1 set and provide the server logs please?

  11. marcinwalus commented on Dec 1, 2016

    @marcinwalus

    This is the query

    let query = PFQuery(className: "Location")
    query.whereKey("objectId", equalTo: locationObjectId)
    query.includeKey("organization,city,city.country,city.country.language")

    pfquerycontroller_m
    streaming_logs_-_microsoft_azure
    pfquerycontroller_m 2

  12. flovilmart commented on Dec 1, 2016

    @flovilmart
    Contributor

    What version of parse server are you using?

  13. marcinwalus commented on Dec 1, 2016

    @marcinwalus

    Parse Dashboard on my azure server says: "Server version: 2.2.25"

  14. marcinwalus commented on Dec 1, 2016

    @marcinwalus

    Parse SDK is: 1.14.2
    An issue is if whet execute this query against Parse.com app it works correctly. When I run it against my Azure parse server app it returns all objects in class.

    When I use url grabbed from Dashboard API Console

    curl 'https://....azurewebsites.net/parse/classes/Location?where=\{%22objectId%22:%2229COAmeqPP%22\}' -XGET -H 'X-Parse-Master-Key: 4243...' -H 'X-Parse-Application-Id: fb6...'
    

    ...it returns correctly only one row

    {"results":[{"objectId":"29COAmeqPP","name":"Leilab 2","createdAt":"2016-09-05T13:31:54.285Z","updatedAt":"2016-09-21T13:56:29.876Z","city":{"__type":"Pointer","className":"City","objectId":"4OwGCKn8Pg"},"organization":{"__type":"Pointer","className":"Organization","objectId":"CdY1INFkSj"},"showOneMapOnly":true,"visible":true,"order":40,"mainAddress":{"__type":"Pointer","className":"Address","objectId":"zTS2qDuzfY"}}]}
  15. flovilmart commented on Dec 1, 2016

    @flovilmart
    Contributor

    Ok, that helps :) and the parse-server version that is deployed on azure?

  16. marcinwalus commented on Dec 1, 2016

    @marcinwalus

    @flovilmart I'm not 100% sure how to check that, sorry. but looking into "node_modules/parse-server/package.json" in my azure wwwroot folder I see "version": "2.2.25" (same as on my Parse Dashboard), so I think this is a version number.

  17. flovilmart commented on Dec 1, 2016

    @flovilmart
    Contributor

    that's very odd then, i'll need to dig deeper into it, doesn't seem to occur with curl nor the JS SDK.

  18. marcinwalus commented on Dec 2, 2016

    @marcinwalus

    @flovilmart Found it! And I need to say that it was partially my fault, however it should be handled in a better way so I think that this is still a bug.
    An issue was that server address I was passing to Parse configuration in my Mac app was "http://..." and not "https://...". After changing to https it works correctly with Parse on Azure.

  19. flovilmart commented on Dec 2, 2016

    @flovilmart
    Contributor

    Awesome! Glad to know!

  20. hbreumelhof commented on Jan 23, 2017

    @hbreumelhof

    This still doesn't seem to be working in the latest version of Parse Server. I'm using the following code where url is {parseInstance}/classes/reportIt?&where={"createdAt":{"$gt":"2016-12-31T13:30:00Z"}} . No constraints such as gte, gt, lte, lt etc work. The API docs state that this should still work in the new Parse Server. Is a fix planned for this? If not, how would I write a workaround for this?

                    WebHeaderCollection parseHeaders = new WebHeaderCollection();
                    parseHeaders.Add("X-Parse-Application-Id", applicationId);
                    parseHeaders.Add("X-Parse-REST-API-Key", applicationKey);
    
                    if (!String.IsNullOrEmpty(this.sessionToken))
                    {
                        parseHeaders.Add("X-Parse-Session-Token", this.sessionToken);
                    }
    
                    WebRequest webRequest = WebRequest.Create(url);
                    webRequest.Method = "GET";
                    webRequest.Headers = parseHeaders;
                    webRequest.Timeout = ConnectionTimeout;
    
                    HttpWebResponse b = (HttpWebResponse)webRequest.GetResponse();
    
                    Stream readerStream = b.GetResponseStream();
                    StreamReader uberReader = new StreamReader(readerStream);
    
                    String response = uberReader.ReadToEnd();
  21. flovilmart commented on Jan 23, 2017

    @flovilmart
    Contributor

    @hbreumelhof can you provide the server logs when running with VERBOSE=1 ? It's likely your query Params are not properly encoded

  22. hbreumelhof commented on Jan 23, 2017

    @hbreumelhof
    [36mverbose[39m: RESPONSE from [GET] /parse/login?username=xxxxx&password=********: {
      "response": {
        "objectId": "xxxxx",
        "createdAt": "2013-08-02T07:54:27.196Z",
        "updatedAt": "2016-08-15T05:28:06.727Z",
        "username": "xxxxx",
        "_perishable_token": "STrmFAuxuU466YckZL8EipolQ",
        "sessionToken": "r:445151684679df12989da5c124b16181"
      }
    } objectId=xxxxx, createdAt=2013-08-02T07:54:27.196Z, updatedAt=2016-08-15T05:28:06.727Z, username=xxxxx, _perishable_token=STrmFAuxuU466YckZL8EipolQ, sessionToken=r:445151684679df12989da5c124b16181
    [36mverbose[39m: REQUEST for [GET] /parse/classes/reportIt?&where=%7b%22createdAt%22%3a%7b%22%24gt%22%3a%222015-12-31T13%3a30%3a00Z%22%7d%7d: {} method=GET, url=/parse/classes/reportIt?&where=%7b%22createdAt%22%3a%7b%22%24gt%22%3a%222015-12-31T13%3a30%3a00Z%22%7d%7d, x-parse-application-id=xxxx, x-parse-rest-api-key=xxxx, x-parse-session-token=r:445151684679df12989da5c124b16181, host=ausyd5752:1337, 
    [36mverbose[39m: RESPONSE from [GET] /parse/classes/reportIt?&where=%7b%22createdAt%22%3a%7b%22%24gt%22%3a%222015-12-31T13%3a30%3a00Z%22%7d%7d: {
      "response": {
        "results": []
      }
    } results=[]
    
    

    So url is /parse/classes/reportIt?&where=%7b%22createdAt%22%3a%7b%22%24gt%22%3a%222015-12-31T13%3a30%3a00Z%22%7d%7d . This seems to work on Parse but not Parse Server. Version I'm running is 2.3.2.

  23. hbreumelhof commented on Jan 25, 2017

    @hbreumelhof

    @flovilmart any thoughts on what the issue may be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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