File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ class Builder extends \Illuminate\Database\Query\Builder {
1818 * @var array
1919 */
2020 protected $ conversion = array (
21- '= ' => '= ' ,
21+ '= ' => '= ' ,
2222 '!= ' => '$ne ' ,
2323 '<> ' => '$ne ' ,
24- '< ' => '$lt ' ,
24+ '< ' => '$lt ' ,
2525 '<= ' => '$lte ' ,
26- '> ' => '$gt ' ,
26+ '> ' => '$gt ' ,
2727 '>= ' => '$gte ' ,
2828 );
2929
@@ -121,7 +121,8 @@ public function getFresh($columns = array('*'))
121121
122122 // Apply order and limit
123123 if ($ this ->orders ) $ pipeline [] = array ('$sort ' => $ this ->orders );
124- if ($ this ->limit ) $ pipeline [] = array ('$limit ' => $ this ->limit );
124+ if ($ this ->offset ) $ pipeline [] = array ('$skip ' => $ this ->offset );
125+ if ($ this ->limit ) $ pipeline [] = array ('$limit ' => $ this ->limit );
125126
126127 $ results = $ this ->collection ->aggregate ($ pipeline );
127128
@@ -150,7 +151,7 @@ public function getFresh($columns = array('*'))
150151 // Apply order, offset and limit
151152 if ($ this ->orders ) $ cursor ->sort ($ this ->orders );
152153 if ($ this ->offset ) $ cursor ->skip ($ this ->offset );
153- if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
154+ if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
154155
155156 // Return results
156157 return iterator_to_array ($ cursor , false );
Original file line number Diff line number Diff line change @@ -105,14 +105,14 @@ protected function getDsn(array $config)
105105 $ dsn .= "{$ username }: {$ password }@ " ;
106106 }
107107
108- $ dsn .= "{$ host }" ;
108+ $ dsn .= "{$ host }" ;
109109
110110 if (isset ($ config ['port ' ]))
111111 {
112112 $ dsn .= ": {$ port }" ;
113113 }
114114
115- $ dsn .= "/ {$ database }" ;
115+ $ dsn .= "/ {$ database }" ;
116116
117117 return $ dsn ;
118118 }
Original file line number Diff line number Diff line change @@ -244,10 +244,20 @@ public function testGroupBy()
244244 $ users = User::groupBy ('age ' )->get ();
245245 $ this ->assertEquals (6 , count ($ users ));
246246
247+ $ users = User::groupBy ('age ' )->skip (1 )->get ();
248+ $ this ->assertEquals (5 , count ($ users ));
249+
250+ $ users = User::groupBy ('age ' )->take (2 )->get ();
251+ $ this ->assertEquals (2 , count ($ users ));
252+
247253 $ users = User::groupBy ('age ' )->orderBy ('age ' , 'desc ' )->get ();
248254 $ this ->assertEquals (37 , $ users [0 ]->age );
249255 $ this ->assertEquals (35 , $ users [1 ]->age );
250256 $ this ->assertEquals (33 , $ users [2 ]->age );
257+
258+ $ users = User::groupBy ('age ' )->skip (1 )->take (2 )->orderBy ('age ' , 'desc ' )->get ();
259+ $ this ->assertEquals (35 , $ users [0 ]->age );
260+ $ this ->assertEquals (33 , $ users [1 ]->age );
251261 }
252262
253263 public function testSubquery ()
You can’t perform that action at this time.
0 commit comments