Skip to content
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

Interpolate objectId and Pointer (as on parse.com) #3711

Closed
awgeorge opened this issue Apr 12, 2017 · 37 comments
Closed

Interpolate objectId and Pointer (as on parse.com) #3711

awgeorge opened this issue Apr 12, 2017 · 37 comments

Comments

@awgeorge
Copy link
Contributor

awgeorge commented Apr 12, 2017

Issue Description

Like: #1014, matchesKeyInQuery returns an empty set.

The ACL is set correctly, and can query both records separately.

Steps to reproduce

where={
  "season": {
    "$select": {
      "key": "objectId",
      "query": {
        "where": {
          "fullIdentifier": "CD117"
        },
        "className": "Season"
      }
    }
  }
}

Expected Results

The results should be returned

Actual Outcome

An empty set is returned

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.3.6
    • Operating System: OSX 10.12.1
    • Hardware: MBP-2015
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.2.11
    • Storage engine: MMAPv1
    • Hardware: ??
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

REQUEST for [GET] /parse/classes/Fixture?where=%7B%22season%22%3A%7B%22%24select%22%3A%7B%22key%22%3A%22objectId%22%2C%22query%22%3A%7B%22where%22%3A%7B%22fullIdentifier%22%3A%22CD117%22%7D%2C%22className%22%3A%22Season%22%7D%7D%7D%7D&include=home%2ChomeResult%2Chome.club%2Chome.ground%2Caway%2CawayResult%2Caway.club%2Cground%2Cseason&limit=1000&order=date: {} method=GET, url=/parse/classes/Fixture?where=%7B%22season%22%3A%7B%22%24select%22%3A%7B%22key%22%3A%22objectId%22%2C%22query%22%3A%7B%22where%22%3A%7B%22fullIdentifier%22%3A%22CD117%22%7D%2C%22className%22%3A%22Season%22%7D%7D%7D%7D&include=home%2ChomeResult%2Chome.club%2Chome.ground%2Caway%2CawayResult%2Caway.club%2Cground%2Cseason&limit=1000&order=date, host=localhost:1337, accept=*/*, x-parse-application-id=[REDACTED], x-parse-client-version=php1.2.2, x-parse-rest-api-key=[REDACTED], 
verbose: RESPONSE from [GET] /parse/classes/Fixture?where=%7B%22season%22%3A%7B%22%24select%22%3A%7B%22key%22%3A%22objectId%22%2C%22query%22%3A%7B%22where%22%3A%7B%22fullIdentifier%22%3A%22CD117%22%7D%2C%22className%22%3A%22Season%22%7D%7D%7D%7D&include=home%2ChomeResult%2Chome.club%2Chome.ground%2Caway%2CawayResult%2Caway.club%2Cground%2Cseason&limit=1000&order=date: {
  "response": {
    "results": []
  }
} results=[]

Related

#1014
#3678 ?

@awgeorge
Copy link
Contributor Author

@flovilmart - Do you know if the request JSON is still correct? Maybe the keys have changed?

@flovilmart
Copy link
Contributor

We haven't changed the API.

@awgeorge
Copy link
Contributor Author

awgeorge commented Apr 23, 2017 via email

@flovilmart
Copy link
Contributor

flovilmart commented Apr 23, 2017 via email

@awgeorge
Copy link
Contributor Author

I'm using the PHP SDK for the main application.

@awgeorge
Copy link
Contributor Author

I've checked the JS SDK - same thing occurs.

@flovilmart
Copy link
Contributor

Is season a pointer?

@awgeorge
Copy link
Contributor Author

It is yes.

@awgeorge
Copy link
Contributor Author

awgeorge commented Apr 24, 2017

More context:

var season = new Parse.Query("Season");
season.equalTo("fullIdentifier", "CD117");
season.find({
    useMasterKey: true,  
    success: function(Seasons){
        console.log(Seasons);
    },
    error: function(e){
        console.log(e);
    }
});

Returns an object: [ ParseObject { _objCount: 0, className: 'Season', id: 'USbmLVfKWW' } ]

var season = new Parse.Query("Season");
season.equalTo("fullIdentifier", "CD117");

var query = new Parse.Query("Fixture");
query.matchesKeyInQuery("season", "objectId", season)
query.find({
    useMasterKey: true,  
    success: function(Fixtures){
        console.log(Fixtures);
    },
    error: function(e){
        console.log(e);
    }
});

Returns an empty array.

@awgeorge
Copy link
Contributor Author

var query = new Parse.Query("Fixture");
query.equalTo("season", new Parse.Object("Season", {id: "USbmLVfKWW"}))
query.find({
    useMasterKey: true,  
    success: function(Fixtures){
        console.log(Fixtures);
    },
    error: function(e){
        console.log(e);
    }
});

Correctly returns the data - so I assume, something has happened to matchesKeyInQuery whereby it can't search for pointers? It used to be able to on the hosted server.

@flovilmart
Copy link
Contributor

Alright, I believe I know what's going on. I'll have a look

@flovilmart flovilmart self-assigned this Apr 24, 2017
@flovilmart flovilmart added type:bug Impaired feature or lacking behavior that is likely assumed troubleshooting labels Apr 24, 2017
@awgeorge
Copy link
Contributor Author

@flovilmart - Anything I can try to help with? I'm on a short timescale and getting pressure from a client. If you can point me in the direction, I maybe able to create a patch. Thanks - appreciate your efforts, keeping parse update.

@flovilmart
Copy link
Contributor

Basically, I believe the issue is that when you use matchesKeyInQuery, it will try to match the objectId instead of the full pointer.

@flovilmart
Copy link
Contributor

To get started, can you open a PR with the failing test?

@awgeorge
Copy link
Contributor Author

I'll get on it -

@flovilmart
Copy link
Contributor

Awesome! Once the test is written, it's gonna be pretty easy to find the underlying issue :)

awgeorge added a commit to awgeorge/parse-server that referenced this issue Apr 28, 2017
@awgeorge
Copy link
Contributor Author

@flovilmart - Test complete, where should I look next, my friend?

@flovilmart
Copy link
Contributor

Probably in RestQuery.js but let me check a few things first about your usage of the API, probably something's amiss.

@awgeorge
Copy link
Contributor Author

awgeorge commented Apr 28, 2017

I may have written the test wrong, but switched the keys around just in case: query.matchesKeyInQuery("season", "objectId", season) same result -

awgeorge added a commit to awgeorge/parse-server that referenced this issue Apr 28, 2017
@awgeorge
Copy link
Contributor Author

Just checked the PHP code - it seems the keys are supposed to be the other way around so - I've updated the JS test. Sorry about that -

@awgeorge
Copy link
Contributor Author

Curious: Looks like it passes using Postgres: https://travis-ci.org/parse-community/parse-server/builds/226664092

@awgeorge
Copy link
Contributor Author

awgeorge commented May 2, 2017

@flovilmart - I'm desperate for a solution as the season starts on Saturday and really need the system to work identically to last year.

So - I've been digging around

const arr = constraint[key];
- Am I warm?

@flovilmart
Copy link
Contributor

I'll work on a fix, I have a pretty good idea of what's going on.

@awgeorge
Copy link
Contributor Author

awgeorge commented May 2, 2017

You would be a life saver -

@flovilmart
Copy link
Contributor

Did you try to use matchesQuery("season", seasonQuery) because it does exactly what you expect it to do.

@awgeorge
Copy link
Contributor Author

awgeorge commented May 3, 2017

I would lead with that next time. ahaha 😞 - Good to know. What's the best course of action:

  1. update all the SDKs to include a message when key=="objectId" (Use matchesQuery instead)
  2. update all the SDKs to call matchesQuery instead if key=="objectId"
  3. Fix the server to allow key=="objectId"
  4. Change the server to internally use the same function as matchesQuery if key=="objectId"
  5. Nothing / maybe update the docs.

@flovilmart
Copy link
Contributor

None of those, this depends on your data structure, any of each could be valid. Not sure how it was working on Parse.com, if because the target field "season" is a pointer, the objectId's are transformed to a pointer matching.

This is not that the server doesn't allow key=='objectId', this is a valid query when you do:

query.matchesKeyInQuery("seasonObjectId", "objectId", seasonQuery);

Where you seasonObjectId column is effectively a string, which is the objectId of a season object.

@awgeorge
Copy link
Contributor Author

awgeorge commented May 3, 2017

I see - that makes sense - so there are cases when people just save the ID instead of using a pointer. - Well, now i'm educated. Maybe FB had a fallback in case it returned no results, try a string value match first, then pointer if that failed.

@flovilmart
Copy link
Contributor

Like I said we could convert those to pointers if the target field is a pointer, did it work before?

@awgeorge
Copy link
Contributor Author

awgeorge commented May 3, 2017 via email

@flovilmart
Copy link
Contributor

I'm looking for a fix now

@flovilmart
Copy link
Contributor

TBH' I still would recommend you to change your code, as I can't guarantee when the fix will be released.

@awgeorge
Copy link
Contributor Author

awgeorge commented May 3, 2017

@flovilmart - Way ahead of you :) - Thanks so much for your direction, in more ways than one, without you parse would likely fall apart.

@flovilmart
Copy link
Contributor

Thanks for the kind words, but many other contributors make it work, and without them, I would fall apart.

@flovilmart flovilmart changed the title matchesKeyInQuery returns an empty set Interpolate objectId and Pointer (as on parse.com) May 10, 2017
@flovilmart flovilmart added enhancement and removed type:bug Impaired feature or lacking behavior that is likely assumed troubleshooting labels May 10, 2017
@flovilmart
Copy link
Contributor

@awgeorge I changed the nature of the issue as it's not a blocker for the moment, but more a nice to have. Is that fine by you?

@flovilmart flovilmart removed their assignment May 10, 2017
@stale
Copy link

stale bot commented Sep 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 18, 2018
@stale stale bot closed this as completed Sep 25, 2018
@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
@parse-github-assistant
Copy link

The label type:feature cannot be used in combination with type:improvement.

@parse-github-assistant parse-github-assistant bot removed the type:feature New feature or improvement of existing feature label Dec 6, 2021
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

3 participants