parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

notEqualTo query not working

Open devKC opened this issue 9 years ago • 16 comments

We use GitHub Issues for bugs.

If you have a non-bug question, ask on Stack Overflow or Server Fault:

  • https://stackoverflow.com/questions/tagged/parse.com
  • https://serverfault.com/tags/parse

You may also search through existing issues before opening a new one: https://github.com/ParsePlatform/Parse-Server/issues?utf8=%E2%9C%93&q=is%3Aissue

--- Please use this template. If you don't use this template, your issue may be closed without comment. ---

Issue Description

Simply, the query with "notEqualTo" is not querying correctly, where value listed in "notEqualTo" is being returned. I am using Parse SDK for iOS.

Steps to reproduce

let query = PFQuery(className: "className")
query.whereKey("userId", notEqualTo: "abc")
query.findObjectsInBackground {}

Expected Results

I expected the query to return rows in the querying class with values for "userId" not equal to "abc".

Actual Outcome

However, the query is returning rows with both "abc" and non "abc" for "userId". "userId" is a column that I created to identify objects separate from the default "objectId".

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : [2.3.7]
    • Operating System: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [Heroku]
  • Database

    • MongoDB version: [3.2.11]
    • Storage engine: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [mLab]

Logs/Trace

no errors

devKC avatar Apr 03 '17 01:04 devKC

Hi I was hoping to follow up on this- any insight would be greatly appreciated!

devKC avatar Apr 14 '17 21:04 devKC

Can you provide the verbose logs please?

flovilmart avatar Apr 14 '17 21:04 flovilmart

@flovilmart - I checked again and now it seems to be working as intended, with no change in coding. I will close this for now and comment on this thread if this happens again in the future. Thank you for following up with me.

devKC avatar Apr 15 '17 01:04 devKC

Don't hesitate to reopen the issue with all relevant logs and informations if needed

flovilmart avatar Apr 15 '17 02:04 flovilmart

@flovilmart - I'm not sure if this is a related issue, but I found that "orQuery" disregards "whereKey" and returns everything. In this case, I'm using PFQueryTableViewController and the code I am running (in queryForTable() function) and the logs is below. I am expecting to get parse objects where uId is equal to the current parse user, but I am fetching parse objects where uId doesn't equal current parse user in addition to those where uId = current parse user. Furthermore, the query disregards whereKey "test1" and "test2" statements and returns all parse objects, even those that doesn't contain "C" in either "test1" or "test2". Is this a similar issue to the one I created originally or is it different since I'm using this in PFTableViewController. Please let me know, as I can close this issue and open a separate issue with this.

(I am running Parse Server 2.3.8)

    ```
    let cQuery = PFQuery(className: self.parseClassName!)
    cQuery.whereKey("userId", equalTo: (PFUser.current()?.objectId)!)
    cQuery.whereKey(“test1”, contains: "C")
    
    let dQuery = PFQuery(className: self.parseClassName!)
    dQuery.whereKey("userId", equalTo: (PFUser.current()?.objectId)!)
    dQuery.whereKey(“test2”, contains: "C")

    let query = PFQuery.orQuery(withSubqueries: [cQuery, dQuery])
    //query.whereKey("userId", equalTo: (PFUser.current()?.objectId)!)
    query.includeKey("testPointer")
    
    return query

logs: Apr 22 10:10:06 heroku/router: at=info method=POST path="/parse/classes/test” host=xxxxxxxxxxxx request_id=ee7d1806-db31-4a57-9515-ccfdd1b9bef5 fwd="205.178.65.227" dyno=web.1 connect=0ms service=92ms status=200 bytes=11911 protocol=https 

devKC avatar Apr 22 '17 17:04 devKC

Can you provide the logs when running with VERBOSE=1?

flovilmart avatar Apr 22 '17 17:04 flovilmart

@flovilmart- Is the following what you need to see? The others were parse object details, but please let me know if there's something specific you are looking for!

Apr 22 11:02:40 app/web.1: verbose: REQUEST for [GET] /parse/classes/test: { 
 Apr 22 11:02:40 app/web.1:   "where": { 
 Apr 22 11:02:40 app/web.1:     "$or": [ 
 Apr 22 11:02:40 app/web.1:       { 
 Apr 22 11:02:40 app/web.1:         "userId": “xyz123”, 
 Apr 22 11:02:40 app/web.1:         "test1": { 
 Apr 22 11:02:40 app/web.1:           "$regex": "\QC\E" 
 Apr 22 11:02:40 app/web.1:         }, 
Apr 22 11:02:40 app/web.1:         "test2": { 
 Apr 22 11:02:40 app/web.1:           "$regex": "\QC\E" 
 Apr 22 11:02:40 app/web.1:         } 
 Apr 22 11:02:40 app/web.1:       }, 
 Apr 22 11:02:40 app/web.1:       {} 
 Apr 22 11:02:40 app/web.1:     ] 
 Apr 22 11:02:40 app/web.1:   }, 
 Apr 22 11:02:40 app/web.1:   "include": “testPointer", 
 Apr 22 11:02:40 app/web.1:   "limit": "10" 
Apr 22 11:02:40 app/web.1: } method=GET, url=/parse/classes/test,

devKC avatar Apr 22 '17 18:04 devKC

Looks like he second clause is empty, probably why you get all elements back

flovilmart avatar Apr 22 '17 19:04 flovilmart

@flovilmart - what I mean is, the way the orQuery is written in Swift, shouldn't the log output be as below? Please let me know if this is not right, in which case I will close the issue and post this question on stackoverflow.

{ 
 Apr 22 11:02:40 app/web.1: "where": { 
 Apr 22 11:02:40 app/web.1: "$or": [ 
 Apr 22 11:02:40 app/web.1: { 
 Apr 22 11:02:40 app/web.1: "userId": “xyz123”, 
 Apr 22 11:02:40 app/web.1: "test1": { 
 Apr 22 11:02:40 app/web.1: "$regex": "\QC\E" 
 Apr 22 11:02:40 app/web.1: } Apr 22 11:02:40 app/web.1: }, 
 Apr 22 11:02:40 app/web.1: { Apr 22 11:02:40 app/web.1: "userId": “xyz123”, 
 Apr 22 11:02:40 app/web.1: "test2": { 
 Apr 22 11:02:40 app/web.1: "$regex": "\QC\E" 
 Apr 22 11:02:40 app/web.1: } Apr 22 11:02:40 app/web.1: } Apr 22 11:02:40 app/web.1: ] 
 Apr 22 11:02:40 app/web.1: }, 
 Apr 22 11:02:40 app/web.1: "include": “testPointer", 
 Apr 22 11:02:40 app/web.1: "limit": "10" 
Apr 22 11:02:40 app/web.1: } method=GET, url=/parse/classes/test,

devKC avatar Apr 23 '17 22:04 devKC

On the last comment, the query seems valid and should not return non matching elements.

flovilmart avatar Apr 23 '17 23:04 flovilmart

The logs in my previous comment was modified to show what I thought it should be given the "orQuery" code I have on the client-side. The actual log output still shows the the empty second query. That's why I was wondering if this might be a SDK bug..

devKC avatar Apr 24 '17 00:04 devKC

Seems to be an issue with the client SDK then. Which is odd.

flovilmart avatar Apr 24 '17 00:04 flovilmart

I wonder if it has anything to do with me calling the query from pfquerytableviewcontroller?

devKC avatar Apr 24 '17 00:04 devKC

Perhaps, does it work outside of it?

flovilmart avatar Apr 24 '17 00:04 flovilmart

@flovilmart - I cleaned my xcode project and rebuilt and is working properly. I think it may have had to do something with local cache. I will close this issue out, thanks for your support!

devKC avatar Apr 24 '17 02:04 devKC

Glad to hear it!

flovilmart avatar Apr 24 '17 11:04 flovilmart