diff --git a/src/Connect/Connector.php b/src/Connect/Connector.php index b01d8c8..4b3d2a0 100644 --- a/src/Connect/Connector.php +++ b/src/Connect/Connector.php @@ -4,6 +4,4 @@ use Illuminate\Database\Connectors\MySqlConnector; -class Connector extends MySqlConnector -{ -} +class Connector extends MySqlConnector {} diff --git a/src/Exceptions/SingleStoreDriverException.php b/src/Exceptions/SingleStoreDriverException.php index bb22fb7..73b6eeb 100644 --- a/src/Exceptions/SingleStoreDriverException.php +++ b/src/Exceptions/SingleStoreDriverException.php @@ -2,6 +2,4 @@ namespace SingleStore\Laravel\Exceptions; -class SingleStoreDriverException extends \Exception -{ -} +class SingleStoreDriverException extends \Exception {} diff --git a/src/Exceptions/UnsupportedFunctionException.php b/src/Exceptions/UnsupportedFunctionException.php index 1fd9e61..ec7861e 100644 --- a/src/Exceptions/UnsupportedFunctionException.php +++ b/src/Exceptions/UnsupportedFunctionException.php @@ -2,6 +2,4 @@ namespace SingleStore\Laravel\Exceptions; -class UnsupportedFunctionException extends SingleStoreDriverException -{ -} +class UnsupportedFunctionException extends SingleStoreDriverException {} diff --git a/src/Fluency/SpatialIndexCommand.php b/src/Fluency/SpatialIndexCommand.php index 91c912b..bdbe014 100644 --- a/src/Fluency/SpatialIndexCommand.php +++ b/src/Fluency/SpatialIndexCommand.php @@ -7,6 +7,4 @@ /** * @method $this resolution(int $resolution) The spatial index resolution */ -class SpatialIndexCommand extends Fluent -{ -} +class SpatialIndexCommand extends Fluent {} diff --git a/src/Query/Grammar.php b/src/Query/Grammar.php index 465dc38..2685725 100644 --- a/src/Query/Grammar.php +++ b/src/Query/Grammar.php @@ -271,4 +271,9 @@ protected function compileDeleteWithJoins(Builder $query, $table, $where): strin return "delete {$deleteTable} from {$table} {$joins} {$where}"; } + + public function useLegacyGroupLimit(Builder $query) + { + return false; + } } diff --git a/tests/Hybrid/GroupLimitTest.php b/tests/Hybrid/GroupLimitTest.php new file mode 100644 index 0000000..f171caa --- /dev/null +++ b/tests/Hybrid/GroupLimitTest.php @@ -0,0 +1,54 @@ +markTestSkipped('requires higher laravel version'); + + return; + } + + $query = DB::table('test')->orderBy('id')->groupLimit(2, 'group'); + $this->assertEquals( + 'select * from (select *, row_number() over (partition by `group` order by `id` asc) as `laravel_row` from `test`) as `laravel_table` where `laravel_row` <= 2 order by `laravel_row`', + $query->toSql() + ); + + if (! $this->runHybridIntegrations()) { + return; + } + + $this->createTable(function (Blueprint $table) { + $table->id(); + $table->integer('group'); + }); + + DB::table('test')->insert([ + ['id' => 1, 'group' => 1], + ['id' => 2, 'group' => 1], + ['id' => 3, 'group' => 1], + ['id' => 4, 'group' => 2], + ['id' => 5, 'group' => 3], + ['id' => 6, 'group' => 3], + ['id' => 7, 'group' => 3], + ['id' => 8, 'group' => 3], + ]); + + $ids = $query->get(['id'])->pluck('id')->toArray(); + sort($ids); + $this->assertEquals($ids, [1, 2, 4, 5, 6]); + } +}