Skip to content

Commit e30e44f

Browse files
committed
Merge branch 'feature/laravel-11'
2 parents 7dd973d + f7eefa9 commit e30e44f

27 files changed

+84
-35
lines changed

.github/workflows/tests-maria.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,33 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18+
version: ["${{ inputs.version }}"]
1819
php: [8.1, 8.2, 8.3]
19-
laravel: [10.*]
20+
laravel: [10.*, 11.*]
2021
stability: [prefer-lowest, prefer-stable]
22+
exclude:
23+
# Laravel 11.x only supports PHP ^8.2
24+
- laravel: 11.*
25+
php: 8.1
26+
# Laravel 11.x required MariaDB 10.10+
27+
- laravel: 11.*
28+
version: 10.3
29+
- laravel: 11.*
30+
version: 10.4
31+
- laravel: 11.*
32+
version: 10.5
33+
- laravel: 11.*
34+
version: 10.6
35+
- laravel: 11.*
36+
version: 10.7
37+
- laravel: 11.*
38+
version: 10.8
39+
- laravel: 11.*
40+
version: 10.9
2141

2242
services:
2343
database:
24-
image: mariadb:${{ inputs.version }}
44+
image: mariadb:${{ matrix.version }}
2545
options: --health-cmd="healthcheck.sh --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
2646
env:
2747
MYSQL_ALLOW_EMPTY_PASSWORD: yes
@@ -55,6 +75,6 @@ jobs:
5575
- name: Execute tests
5676
run: vendor/bin/pest
5777
env:
58-
DB_CONNECTION: mysql
78+
DB_CONNECTION: ${{ matrix.laravel == '10.*' && 'mysql' || 'mariadb' }}
5979
DB_DATABASE: mysql
6080
DB_USERNAME: root

.github/workflows/tests-mysql.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
php: [8.1, 8.2, 8.3]
19-
laravel: [10.*]
19+
laravel: [10.*, 11.*]
2020
stability: [prefer-lowest, prefer-stable]
21+
exclude:
22+
# Laravel 11.x only supports PHP ^8.2
23+
- laravel: 11.*
24+
php: 8.1
2125

2226
services:
2327
database:
@@ -61,3 +65,4 @@ jobs:
6165
DB_DATABASE: testing
6266
DB_USERNAME: testing
6367
DB_PASSWORD: testing
68+
DB_COLLATION: ${{ inputs.version == '5.7' && 'utf8mb4_general_ci' || 'utf8mb4_0900_ai_ci' }}

.github/workflows/tests-pgsql.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
php: [8.1, 8.2, 8.3]
19-
laravel: [10.*]
19+
laravel: [10.*, 11.*]
2020
stability: [prefer-lowest, prefer-stable]
21+
exclude:
22+
# Laravel 11.x only supports PHP ^8.2
23+
- laravel: 11.*
24+
php: 8.1
2125

2226
services:
2327
database:
@@ -56,4 +60,6 @@ jobs:
5660
run: vendor/bin/pest
5761
env:
5862
DB_CONNECTION: pgsql
59-
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
63+
DB_DATABASE: postgres
64+
DB_USERNAME: postgres
65+
DB_PASSWORD: postgres

.github/workflows/tests-sqlite.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
php: [8.1, 8.2, 8.3]
14-
laravel: [10.*]
14+
laravel: [10.*, 11.*]
1515
stability: [prefer-lowest, prefer-stable]
16+
exclude:
17+
# Laravel 11.x only supports PHP ^8.2
18+
- laravel: 11.*
19+
php: 8.1
1620

1721
steps:
1822
- name: Checkout code

.github/workflows/tests-sqlsrv.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
php: [8.1, 8.2, 8.3]
19-
laravel: [10.*]
19+
laravel: [10.*, 11.*]
2020
stability: [prefer-lowest, prefer-stable]
21+
exclude:
22+
# Laravel 11.x only supports PHP ^8.2
23+
- laravel: 11.*
24+
php: 8.1
2125

2226
services:
2327
database:
@@ -57,4 +61,6 @@ jobs:
5761
run: vendor/bin/pest
5862
env:
5963
DB_CONNECTION: sqlsrv
60-
DATABASE_URL: sqlsrv://sa:Password_123@localhost:1433/master
64+
DB_DATABASE: master
65+
DB_USERNAME: sa
66+
DB_PASSWORD: Password_123

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
],
1919
"require": {
2020
"php": "^8.1",
21-
"illuminate/contracts": "^10.13.1",
22-
"illuminate/database": "^10.13.1",
23-
"illuminate/support": "^10.0"
21+
"illuminate/contracts": "^10.13.1|^11.0",
22+
"illuminate/database": "^10.13.1|^11.0",
23+
"illuminate/support": "^10.0|^11.0"
2424
},
2525
"require-dev": {
2626
"larastan/larastan": "^2.7.0",
2727
"laravel/pint": "^1.0",
28-
"nunomaduro/collision": "^7.0.0",
29-
"orchestra/testbench": "^8.0",
28+
"nunomaduro/collision": "^7.0|^8.0",
29+
"orchestra/testbench": "^8.0|^9.0",
3030
"pestphp/pest": "^2.28.1",
3131
"pestphp/pest-plugin-laravel": "^2.2.0",
3232
"phpstan/extension-installer": "^1.1",

src/Concerns/IdentifiesDriver.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
namespace Tpetry\QueryExpressions\Concerns;
66

77
use Illuminate\Database\Grammar;
8+
use Illuminate\Database\Query\Grammars\MariaDbGrammar as MariaQueryGrammar;
89
use Illuminate\Database\Query\Grammars\MySqlGrammar as MysqlQueryGrammar;
910
use Illuminate\Database\Query\Grammars\PostgresGrammar as PgsqlQueryGrammar;
1011
use Illuminate\Database\Query\Grammars\SQLiteGrammar as SqliteQueryGrammar;
1112
use Illuminate\Database\Query\Grammars\SqlServerGrammar as SqlsrvQueryGrammar;
13+
use Illuminate\Database\Schema\Grammars\MariaDbGrammar as MariaSchemaGrammar;
1214
use Illuminate\Database\Schema\Grammars\MySqlGrammar as MysqlSchemaGrammar;
1315
use Illuminate\Database\Schema\Grammars\PostgresGrammar as PgsqlSchemaGrammar;
1416
use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SqliteSchemaGrammar;
@@ -18,11 +20,12 @@
1820
trait IdentifiesDriver
1921
{
2022
/**
21-
* @return 'mysql'|'pgsql'|'sqlite'|'sqlsrv'
23+
* @return 'mariadb'|'mysql'|'pgsql'|'sqlite'|'sqlsrv'
2224
*/
2325
protected function identify(Grammar $grammar): string
2426
{
2527
return match (true) {
28+
$this->isMaria($grammar) => 'mariadb',
2629
$this->isMysql($grammar) => 'mysql',
2730
$this->isPgsql($grammar) => 'pgsql',
2831
$this->isSqlite($grammar) => 'sqlite',
@@ -31,6 +34,11 @@ protected function identify(Grammar $grammar): string
3134
};
3235
}
3336

37+
protected function isMaria(Grammar $grammar): bool
38+
{
39+
return $grammar instanceof MariaQueryGrammar || $grammar instanceof MariaSchemaGrammar;
40+
}
41+
3442
protected function isMysql(Grammar $grammar): bool
3543
{
3644
return $grammar instanceof MysqlQueryGrammar || $grammar instanceof MysqlSchemaGrammar;

src/Function/Aggregate/CountFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function getValue(Grammar $grammar): string
2424
$filter = $this->stringize($grammar, $this->filter);
2525

2626
return match ($this->identify($grammar)) {
27-
'mysql' => "sum({$filter})",
27+
'mariadb', 'mysql' => "sum({$filter})",
2828
'pgsql', 'sqlite' => "count(*) filter (where {$filter})",
2929
'sqlsrv' => "sum(case when {$filter} then 1 else 0 end)",
3030
};

src/Function/Aggregate/SumFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getValue(Grammar $grammar): string
2626
$filter = $this->stringize($grammar, $this->filter);
2727

2828
return match ($this->identify($grammar)) {
29-
'mysql', 'sqlsrv' => "sum(case when {$filter} then {$value} else 0 end)",
29+
'mariadb', 'mysql', 'sqlsrv' => "sum(case when {$filter} then {$value} else 0 end)",
3030
'pgsql', 'sqlite' => "sum({$value}) filter (where {$filter})",
3131
};
3232
}

src/Function/Comparison/StrListContains.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getValue(Grammar $grammar)
2828

2929
// PostgreSQL: The string_to_array is not used because citext values would be cast to case-sensitive text type
3030
return match ($this->identify($grammar)) {
31-
'mysql' => "FIND_IN_SET({$str}, {$strList}) > 0",
31+
'mariadb', 'mysql' => "FIND_IN_SET({$str}, {$strList}) > 0",
3232
'pgsql', 'sqlite' => "({$strList} like {$str} or {$strList} like (({$str})||',%') or {$strList} like ('%,'||({$str})||',%') or {$strList} like ('%,'||({$str})))",
3333
'sqlsrv' => "({$strList} like {$str} or {$strList} like concat({$str},',%') or {$strList} like concat('%,',{$str},',%') or {$strList} like concat('%,',{$str}))",
3434
};

0 commit comments

Comments
 (0)