File tree 2 files changed +57
-2
lines changed
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)
140
140
*/
141
141
public function equalTo ($ key , $ value )
142
142
{
143
- $ this ->where [ $ key] = $ value ;
143
+ $ this ->addCondition ( $ key, ' $eq ' , $ value) ;
144
144
145
145
return $ this ;
146
146
}
Original file line number Diff line number Diff line change @@ -2663,7 +2663,9 @@ public function testGetAndSetConditions()
2663
2663
2664
2664
$ this ->assertEquals ([
2665
2665
'where ' => [
2666
- 'key ' => 'value ' ,
2666
+ 'key ' => [
2667
+ '$eq ' => 'value ' ,
2668
+ ],
2667
2669
'key2 ' => [
2668
2670
'$ne ' => 'value2 ' ,
2669
2671
],
@@ -2719,4 +2721,57 @@ public function testUnknownCondition()
2719
2721
'unrecognized ' => 1
2720
2722
]);
2721
2723
}
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
+ }
2722
2777
}
You can’t perform that action at this time.
0 commit comments