Skip to content

Commit

Permalink
Merge 2a84243 into 0570f15
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored May 13, 2023
2 parents 0570f15 + 2a84243 commit 72a3246
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Parse/ParseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function get($objectId, $useMasterKey = false)
*/
public function equalTo($key, $value)
{
$this->where[$key] = $value;
$this->addCondition($key, '$eq', $value);

return $this;
}
Expand Down
57 changes: 56 additions & 1 deletion tests/Parse/ParseQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,9 @@ public function testGetAndSetConditions()

$this->assertEquals([
'where' => [
'key' => 'value',
'key' => [
'$eq' => 'value',
],
'key2' => [
'$ne' => 'value2',
],
Expand Down Expand Up @@ -2719,4 +2721,57 @@ public function testUnknownCondition()
'unrecognized' => 1
]);
}

/**
* @group query-equalTo-conditions
*/
public function testEqualToWithSameKeyDoesNotOverrideOtherConditions()
{
$baz = new ParseObject('TestObject');
$baz->setArray('fooStack', [
[
'status' => 'baz'
],
[
'status' => 'bar'
]
]);
$baz->save();

$bar = new ParseObject('TestObject');
$bar->setArray('fooStack', [
[
'status' => 'bar'
]
]);
$bar->save();

$qux = new ParseObject('TestObject');
$qux->setArray('fooStack', [
[
'status' => 'bar',
],
[
'status' => 'qux'
]
]);
$qux->save();

$query = new ParseQuery('TestObject');
$query->notEqualTo('fooStack.status', 'baz');
$query->equalTo('fooStack.status', 'bar');

$this->assertEquals(2, $query->count(true));

$this->assertSame([
'where' => [
'fooStack.status' => [
'$ne' => 'baz',
'$eq' => 'bar',
]
],
'limit' => 0,
'count' => 1,
], $query->_getOptions());
}
}

0 comments on commit 72a3246

Please sign in to comment.