File tree Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ public function get($objectId, $useMasterKey = false)
140140 */
141141 public function equalTo ($ key , $ value )
142142 {
143- $ this ->where [ $ key] = $ value ;
143+ $ this ->addCondition ( $ key, ' $eq ' , $ value) ;
144144
145145 return $ this ;
146146 }
Original file line number Diff line number Diff line change @@ -2663,7 +2663,9 @@ public function testGetAndSetConditions()
26632663
26642664 $ this ->assertEquals ([
26652665 'where ' => [
2666- 'key ' => 'value ' ,
2666+ 'key ' => [
2667+ '$eq ' => 'value ' ,
2668+ ],
26672669 'key2 ' => [
26682670 '$ne ' => 'value2 ' ,
26692671 ],
@@ -2719,4 +2721,57 @@ public function testUnknownCondition()
27192721 'unrecognized ' => 1
27202722 ]);
27212723 }
2724+
2725+ /**
2726+ * @group query-equalTo-conditions
2727+ */
2728+ public function testEqualToWithSameKeyDoesNotOverrideOtherConditions ()
2729+ {
2730+ $ baz = new ParseObject ('TestObject ' );
2731+ $ baz ->setArray ('fooStack ' , [
2732+ [
2733+ 'status ' => 'baz '
2734+ ],
2735+ [
2736+ 'status ' => 'bar '
2737+ ]
2738+ ]);
2739+ $ baz ->save ();
2740+
2741+ $ bar = new ParseObject ('TestObject ' );
2742+ $ bar ->setArray ('fooStack ' , [
2743+ [
2744+ 'status ' => 'bar '
2745+ ]
2746+ ]);
2747+ $ bar ->save ();
2748+
2749+ $ qux = new ParseObject ('TestObject ' );
2750+ $ qux ->setArray ('fooStack ' , [
2751+ [
2752+ 'status ' => 'bar ' ,
2753+ ],
2754+ [
2755+ 'status ' => 'qux '
2756+ ]
2757+ ]);
2758+ $ qux ->save ();
2759+
2760+ $ query = new ParseQuery ('TestObject ' );
2761+ $ query ->notEqualTo ('fooStack.status ' , 'baz ' );
2762+ $ query ->equalTo ('fooStack.status ' , 'bar ' );
2763+
2764+ $ this ->assertEquals (2 , $ query ->count (true ));
2765+
2766+ $ this ->assertSame ([
2767+ 'where ' => [
2768+ 'fooStack.status ' => [
2769+ '$ne ' => 'baz ' ,
2770+ '$eq ' => 'bar ' ,
2771+ ]
2772+ ],
2773+ 'limit ' => 0 ,
2774+ 'count ' => 1 ,
2775+ ], $ query ->_getOptions ());
2776+ }
27222777}
You can’t perform that action at this time.
0 commit comments