@@ -41,9 +41,11 @@ public function testInnerJoinT1()
41
41
function ($ r1 , $ r2 ) {
42
42
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
43
43
}
44
- )->run ($ this ->conn );
44
+ )
45
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
46
+ ->run ($ this ->conn );
45
47
46
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
48
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
47
49
}
48
50
49
51
public function testInnerJoinT2 ()
@@ -65,9 +67,11 @@ public function testInnerJoinT2()
65
67
function ($ r1 , $ r2 ) {
66
68
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
67
69
}
68
- )->run ($ this ->conn );
70
+ )
71
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
72
+ ->run ($ this ->conn );
69
73
70
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
74
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
71
75
}
72
76
73
77
public function testOuterJoinT1 ()
@@ -93,9 +97,11 @@ public function testOuterJoinT1()
93
97
function ($ r1 , $ r2 ) {
94
98
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
95
99
}
96
- )->run ($ this ->conn );
100
+ )
101
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
102
+ ->run ($ this ->conn );
97
103
98
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
104
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
99
105
}
100
106
101
107
public function testOuterJoinT2 ()
@@ -118,9 +124,11 @@ public function testOuterJoinT2()
118
124
function ($ r1 , $ r2 ) {
119
125
return $ r1 ('other ' )->eq ($ r2 ('id ' ));
120
126
}
121
- )->run ($ this ->conn );
127
+ )
128
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
129
+ ->run ($ this ->conn );
122
130
123
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
131
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
124
132
}
125
133
126
134
public function testEqJoinOther ()
@@ -142,9 +150,10 @@ public function testEqJoinOther()
142
150
143
151
$ res = $ this ->db ()->table ('t1 ' )
144
152
->eqJoin ('other ' , $ this ->db ()->table ('t2 ' ))
153
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
145
154
->run ($ this ->conn );
146
155
147
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
156
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
148
157
}
149
158
150
159
public function testEqJoinId ()
@@ -162,9 +171,10 @@ public function testEqJoinId()
162
171
163
172
$ res = $ this ->db ()->table ('t1 ' )
164
173
->eqJoin ('id ' , $ this ->db ()->table ('t2 ' ), array ('index ' => 'other ' ))
174
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
165
175
->run ($ this ->conn );
166
176
167
- $ this ->assertEquals ($ excpected , $ this ->toArray ($ res-> toArray () ));
177
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
168
178
}
169
179
170
180
public function testEqJoinFunc ()
@@ -188,9 +198,10 @@ public function testEqJoinFunc()
188
198
->eqJoin (function ($ x ) {
189
199
return $ x ('other ' );
190
200
}, $ this ->db ()->table ('t2 ' ))
201
+ ->orderBy (array (r \row ("left " )->getField ("id " ), r \row ("right " )->getField ("id " )))
191
202
->run ($ this ->conn );
192
203
193
- $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftId ($ res ));
204
+ $ this ->assertEquals ($ excpected , $ this ->orderArrayByLeftAndRightId ($ res ));
194
205
}
195
206
196
207
public function testEqJoinZip ()
@@ -203,15 +214,19 @@ public function testEqJoinZip()
203
214
$ res = $ this ->db ()->table ('t1 ' )
204
215
->eqJoin ('id ' , $ this ->db ()->table ('t2 ' ), array ('index ' => 'other ' ))
205
216
->zip ()
217
+ ->orderBy ("id " )
206
218
->run ($ this ->conn );
207
219
208
220
$ this ->assertEquals ($ excpected , $ this ->orderArrayById ($ res ));
209
221
}
210
222
211
- protected function orderArrayByLeftId ($ data )
223
+ protected function orderArrayByLeftAndRightId ($ data )
212
224
{
213
- $ data = $ this ->toArray ($ data-> toArray () );
225
+ $ data = $ this ->toArray ($ data );
214
226
usort ($ data , function ($ a , $ b ) {
227
+ if ($ a ['left ' ]['id ' ] == $ b ['left ' ]['id ' ]) {
228
+ return $ a ['right ' ]['id ' ] > $ b ['right ' ]['id ' ];
229
+ }
215
230
return $ a ['left ' ]['id ' ] > $ b ['left ' ]['id ' ];
216
231
});
217
232
@@ -220,7 +235,7 @@ protected function orderArrayByLeftId($data)
220
235
221
236
protected function orderArrayById ($ data )
222
237
{
223
- $ data = $ this ->toArray ($ data-> toArray () );
238
+ $ data = $ this ->toArray ($ data );
224
239
usort ($ data , function ($ a , $ b ) {
225
240
return strcmp ($ a ['id ' ], $ b ['id ' ]);
226
241
});
0 commit comments