File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ public static function getInnerSelectColumns($builder)
125125 // is totally reasonable. We'll look for both
126126 // quoted and unquoted, as a kindness.
127127 // See https://github.com/hammerstonedev/fast-paginate/pull/57
128+ $ column = $ column instanceof Expression ? $ column ->getValue ($ base ->grammar ) : $ column ;
129+
128130 return [
129131 $ column ,
130132 $ base ->grammar ->wrap ($ column ),
Original file line number Diff line number Diff line change @@ -235,6 +235,21 @@ public function unquoted_selects_are_preserved_if_used_in_order_by()
235235 );
236236 }
237237
238+ /** @test */
239+ public function using_expressions_for_order_work ()
240+ {
241+ $ queries = $ this ->withQueriesLogged (function () use (&$ results ) {
242+ $ results = User::query ()->selectRaw ('(select 1) as computed_column ' )->orderBy (
243+ User::query ()->select ('name ' )->orderBy ('name ' )->limit (1 )->getQuery ()
244+ )->fastPaginate ();
245+ });
246+
247+ $ this ->assertEquals (
248+ 'select `users`.`id` from `users` order by (select `name` from `users` order by `name` asc limit 1) asc limit 15 offset 0 ' ,
249+ $ queries [1 ]['query ' ]
250+ );
251+ }
252+
238253 /** @test */
239254 public function havings_defer ()
240255 {
You can’t perform that action at this time.
0 commit comments