Skip to content

Commit

Permalink
Support Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Mar 9, 2024
1 parent 25382b6 commit 1e70630
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:

strategy:
matrix:
php: [ 8.3, 8.2, 8.1 ]
database: [ mysql, mariadb, pgsql, sqlite, sqlsrv, singlestore, firebird ]
php: [ 8.3, 8.2 ]
database: [ mysql, mariadb, pgsql, sqlite, sqlsrv ] # TODO[L11]: singlestore, firebird
release: [ stable, lowest ]
include:
- php: 8.3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Static Analysis

on: [ push, pull_request ]
on: workflow_dispatch # TODO[L11]: [ push, pull_request ]

jobs:
phpstan:
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ $tree = User::from('tree')
If you want to implement recursive relationships, you can use this
package: [staudenmeir/laravel-adjacency-list](https://github.com/staudenmeir/laravel-adjacency-list)

### Package Conflicts

- `staudenmeir/eloquent-eager-limit`: Replace both packages
with [staudenmeir/eloquent-eager-limit-x-laravel-cte](https://github.com/staudenmeir/eloquent-eager-limit-x-laravel-cte)
to use them on the same model.

### Lumen

If you are using Lumen, you have to instantiate the query builder manually:
Expand Down
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
}
],
"require": {
"php": "^8.1",
"illuminate/database": "^10.0"
"php": "^8.2",
"illuminate/database": "^11.0"
},
"require-dev": {
"harrygulliford/laravel-firebird": "^3.2",
"orchestra/testbench": "^8.0",
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.1",
"singlestoredb/singlestoredb-laravel": "^1.5.1"
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
version: '3.8'

services:
php8.1:
image: ghcr.io/staudenmeir/php:8.1
working_dir: /var/www/html
networks:
- test
volumes:
- .:/var/www/html:delegated
- ~/.cache/composer/files:/root/.composer/cache/files
php8.2:
image: ghcr.io/staudenmeir/php:8.2
working_dir: /var/www/html
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
version: '3.8'

services:
php8.1:
image: ghcr.io/staudenmeir/php:8.1
working_dir: /var/www/html
networks:
- test
volumes:
- .:/var/www/html:delegated
- .docker/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
php8.2:
image: ghcr.io/staudenmeir/php:8.2
working_dir: /var/www/html
Expand Down
10 changes: 10 additions & 0 deletions src/Connections/MariaDbConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Staudenmeir\LaravelCte\Connections;

use Illuminate\Database\MariaDbConnection as Base;

class MariaDbConnection extends Base
{
use CreatesQueryBuilder;
}
2 changes: 2 additions & 0 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Connectors\ConnectionFactory as Base;
use InvalidArgumentException;
use Staudenmeir\LaravelCte\Connections\FirebirdConnection;
use Staudenmeir\LaravelCte\Connections\MariaDbConnection;
use Staudenmeir\LaravelCte\Connections\MySqlConnection;
use Staudenmeir\LaravelCte\Connections\OracleConnection;
use Staudenmeir\LaravelCte\Connections\PostgresConnection;
Expand Down Expand Up @@ -37,6 +38,7 @@ protected function createConnection($driver, $connection, $database, $prefix = '

return match ($driver) {
'mysql' => new MySqlConnection($connection, $database, $prefix, $config),
'mariadb' => new MariaDbConnection($connection, $database, $prefix, $config),
'pgsql' => new PostgresConnection($connection, $database, $prefix, $config),
'sqlite' => new SQLiteConnection($connection, $database, $prefix, $config),
'sqlsrv' => new SqlServerConnection($connection, $database, $prefix, $config),
Expand Down
11 changes: 11 additions & 0 deletions src/Query/Grammars/MariaDbGrammar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Staudenmeir\LaravelCte\Query\Grammars;

use Illuminate\Database\Query\Grammars\MariaDbGrammar as Base;
use Staudenmeir\LaravelCte\Query\Grammars\Traits\CompilesMySqlExpressions;

class MariaDbGrammar extends Base
{
use CompilesMySqlExpressions;
}
12 changes: 0 additions & 12 deletions src/Query/Grammars/Traits/CompilesSqlServerExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ public function compileSelect(Builder $query)
return $this->compileSelectParent($query);
}

/**
* Compile a common table expression for a query. TODO[L11]
*
* @param string $sql
* @param \Illuminate\Database\Query\Builder $query
* @return string
*/
protected function compileTableExpression($sql, $query)
{
return $this->compileExpressions($query, $query->expressions).' '.parent::compileTableExpression($sql, $query);
}

/**
* Get the "recursive" keyword.
*
Expand Down
9 changes: 3 additions & 6 deletions src/Query/Traits/BuildsExpressionQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Query\Processors\Processor;
use RuntimeException;
use Staudenmeir\LaravelCte\Query\Grammars\FirebirdGrammar;
use Staudenmeir\LaravelCte\Query\Grammars\MariaDbGrammar;
use Staudenmeir\LaravelCte\Query\Grammars\MySqlGrammar;
use Staudenmeir\LaravelCte\Query\Grammars\OracleGrammar;
use Staudenmeir\LaravelCte\Query\Grammars\PostgresGrammar;
Expand Down Expand Up @@ -74,6 +75,7 @@ protected function getQueryGrammar(Connection $connection)

$grammar = match ($driver) {
'mysql' => new MySqlGrammar(),
'mariadb' => new MariaDbGrammar(),
'pgsql' => new PostgresGrammar(),
'sqlite' => new SQLiteGrammar(),
'sqlsrv' => new SqlServerGrammar(),
Expand All @@ -83,12 +85,7 @@ protected function getQueryGrammar(Connection $connection)
default => throw new RuntimeException('This database is not supported.'), // @codeCoverageIgnore
};

// TODO[L11]
if (method_exists($grammar, 'setConnection')) {
$grammar->setConnection($connection);
}

return $grammar;
return $grammar->setConnection($connection);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function getEnvironmentSetUp($app)

protected function getPackageProviders($app)
{
return []; // TODO[L11]
return [SingleStoreProvider::class, FirebirdServiceProvider::class];
}
}
2 changes: 1 addition & 1 deletion tests/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'engine' => null,
],
'mariadb' => [
'driver' => 'mysql',
'driver' => 'mariadb',
'host' => 'mariadb',
'port' => '3306',
'database' => 'test',
Expand Down

0 comments on commit 1e70630

Please sign in to comment.