-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
ParseQuery::equalTo
with strange behavior
#476
Comments
Can you write a failing test case? The javascript SDK has similar behavior https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseQuery.js#L1216 (my Apple M1 chip is preventing me from running the tests, im looking into it) |
Hello @dplewis , I have no experience with open source contribution, in fact this is the first I do a PR for an open source project, anything just to report. Below is the PR with the tests I did. I did a test that queries the database and is returning And the other test is about what I related about equalTo overwriting the previous queries that use the same Note: I can't do the test where the equalTo() is called before the notEqualTo, because it launches a Note: I made the same query on the mongodb compass and the result is expected to be only 2 |
A developer just posted a similar issue with the JS SDK. Does this exist there as well? |
yes, my friend from work when trying to do the same query I did in parse-php-sdk the query didn't work correctly, I don't know exactly the error due to lack of js expertise, but I know it didn't work properly. JS SDK PHP SDK When looking at this piece of code, it looks a lot like the php SDK. In PHP I know the error is because The main question is to understand why the |
Maybe because we want |
Issue Description
Hello, I currently have a use case that requires making 2 conditions in the same field but with different values.
However, when using
equalTo(field, value)
and thennotEqualTo(field, value)
it returns awarning
Message:
Warning: Illegal string offset '$ne'
This happens because when trying to add the
$ne
condition to the$this->where
in theParseQuery::addCondition($key, $condition, $value)
method, the$this->where[$key]
is a string, due to theParseQuery::equalTo($key, $value)
method adding the value directly to the$this->where
arraySteps to reproduce
Note: If the
equalTo
query is the last one to be called, it overrides the previous conditionNote: the code above is just a use case, of course the query itself doesn’t make much sense
Result of the query structure above
Solution
Instead of using
$this->where[$key]
inside theParseQuery::equalTo()
method, use the$this->addCondition($key, '$eq', $value)
method.I don't know if there is any special reason for using $this->where directly in the
ParseQuery::equalTo()
method instead of using$this->addCondition($key, '$eq', $value)
, but with aggregation the query listed above works normally.With aggregate
Environment Details
The text was updated successfully, but these errors were encountered: