Skip to content

Commit a2d990f

Browse files
authored
Fix mariadb CI build (#721)
1 parent 6dac52e commit a2d990f

File tree

6 files changed

+65
-11
lines changed

6 files changed

+65
-11
lines changed

.env.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
DBA_PLATFORM=mysql
12
DBA_HOST=mysql80.ab
23
DBA_USER=testuser
34
DBA_PASSWORD=test

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
dependencies: "highest"
5050
- php-version: '8.1'
5151
db-image: 'mariadb:latest'
52+
platform: 'mariadb'
5253
reflector: "mysqli"
5354
mode: "recording"
5455
dependencies: "highest"
@@ -60,6 +61,7 @@ jobs:
6061
dependencies: "highest"
6162
- php-version: '8.2'
6263
db-image: 'mariadb:latest'
64+
platform: 'mariadb'
6365
reflector: "mysqli"
6466
mode: "recording"
6567
dependencies: "highest"
@@ -82,6 +84,7 @@ jobs:
8284
dependencies: "highest"
8385

8486
env:
87+
DBA_PLATFORM: ${{ matrix.platform }}
8588
DBA_REFLECTOR: ${{ matrix.reflector }}
8689
DBA_MODE: ${{ matrix.mode }}
8790

tests/ReflectorFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static function create(string $cacheDir): QueryReflector
3434
$ssl = false;
3535
$mode = getenv('DBA_MODE') ?: self::MODE_RECORDING;
3636
$reflector = getenv('DBA_REFLECTOR') ?: 'mysqli';
37+
$platform = getenv('DBA_PLATFORM') ?: 'mysql';
3738
} else {
3839
$host = getenv('DBA_HOST') ?: $_ENV['DBA_HOST'];
3940
$user = getenv('DBA_USER') ?: $_ENV['DBA_USER'];
@@ -42,10 +43,12 @@ public static function create(string $cacheDir): QueryReflector
4243
$ssl = (string) (getenv('DBA_SSL') ?: $_ENV['DBA_SSL'] ?? '');
4344
$mode = getenv('DBA_MODE') ?: $_ENV['DBA_MODE'];
4445
$reflector = getenv('DBA_REFLECTOR') ?: $_ENV['DBA_REFLECTOR'];
46+
$platform = getenv('DBA_PLATFORM') ?: $_ENV['DBA_PLATFORM'];
4547
}
4648

4749
// make env vars available to tests, in case non are defined yet
4850
$_ENV['DBA_REFLECTOR'] = $reflector;
51+
$_ENV['DBA_PLATFORM'] = $platform;
4952

5053
// we need to record the reflection information in both, phpunit and phpstan since we are replaying it in both CI jobs.
5154
// in a regular application you will use phpstan-dba only within your phpstan CI job, therefore you only need 1 cache-file.

tests/rules/SyntaxErrorInPreparedStatementMethodRuleTest.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public static function getAdditionalConfigFiles(): array
3131
public function testSyntaxErrorInQueryRule(): void
3232
{
3333
if (MysqliQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
34+
$error = "Query error: Unknown column 'asdsa' in 'where clause' (1054).";
35+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
36+
$error = "Query error: Unknown column 'asdsa' in 'WHERE' (1054).";
37+
}
38+
3439
$expectedErrors = [
3540
[
3641
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
@@ -61,7 +66,7 @@ public function testSyntaxErrorInQueryRule(): void
6166
107,
6267
],
6368
[
64-
"Query error: Unknown column 'asdsa' in 'where clause' (1054).",
69+
$error,
6570
122,
6671
],
6772
[
@@ -165,6 +170,10 @@ public function testSyntaxErrorInQueryRule(): void
165170
],
166171
];
167172
} elseif (PdoMysqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
173+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
174+
self::markTestSkipped("We don't test all variants of expectations for all drivers");
175+
}
176+
168177
$expectedErrors = [
169178
[
170179
"Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (42000).",
@@ -256,17 +265,24 @@ public function testBug94()
256265
public function testSyntaxErrorWithInferencePlaceholder()
257266
{
258267
if (MysqliQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
268+
$platform = $_ENV['DBA_PLATFORM'];
269+
270+
$error = "Query error: Unknown column 'does_not_exist' in 'field list' (1054).";
271+
if ($platform === "mariadb") {
272+
$error = "Query error: Unknown column 'does_not_exist' in 'SELECT' (1054).";
273+
}
274+
259275
$expectedErrors = [
260276
[
261-
"Query error: Unknown column 'does_not_exist' in 'field list' (1054).",
277+
$error,
262278
12,
263279
],
264280
[
265-
"Query error: Unknown column 'does_not_exist' in 'field list' (1054).",
281+
$error,
266282
36,
267283
],
268284
[
269-
"Query error: Unknown column 'does_not_exist' in 'field list' (1054).",
285+
$error,
270286
60,
271287
],
272288
];
@@ -292,6 +308,10 @@ public function testSyntaxErrorWithInferencePlaceholder()
292308
],
293309
];
294310
} elseif (PdoMysqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
311+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
312+
self::markTestSkipped("We don't test all variants of expectations for all drivers");
313+
}
314+
295315
$expectedErrors = [
296316
[
297317
"Query error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'does_not_exist' in 'field list' (42S22).",

tests/rules/SyntaxErrorInQueryFunctionRuleTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function testSyntaxErrorInQueryRule(): void
3939
public function getExpectedErrors(): array
4040
{
4141
$dbaReflector = getenv('DBA_REFLECTOR');
42+
$platform = $_ENV['DBA_PLATFORM'];
4243

4344
switch ($dbaReflector) {
4445
case MysqliQueryReflector::NAME:
@@ -52,7 +53,9 @@ public function getExpectedErrors(): array
5253
19,
5354
],
5455
[
55-
"Query error: Unknown column 'asdsa' in 'where clause' (1054).",
56+
$platform === 'mariadb' ?
57+
"Query error: Unknown column 'asdsa' in 'WHERE' (1054)."
58+
: "Query error: Unknown column 'asdsa' in 'where clause' (1054).",
5659
39,
5760
],
5861
];
@@ -87,6 +90,10 @@ public function getExpectedErrors(): array
8790
],
8891
];
8992
case PdoMysqlQueryReflector::NAME:
93+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
94+
self::markTestSkipped("We don't test all variants of expectations for all drivers");
95+
}
96+
9097
return [
9198
[
9299
"Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (42000).",

tests/rules/SyntaxErrorInQueryMethodRuleTest.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ public static function getAdditionalConfigFiles(): array
3131
public function testSyntaxErrorInQueryRule(): void
3232
{
3333
if (MysqliQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
34+
$errSelect = "Query error: Unknown column 'doesNotExist' in 'field list' (1054).";
35+
$errWhere = "Query error: Unknown column 'doesNotExist' in 'where clause' (1054).";
36+
$errOrder = "Query error: Unknown column 'doesNotExist' in 'order clause' (1054).";
37+
$errGroup = "Query error: Unknown column 'doesNotExist' in 'group statement' (1054).";
38+
$errWhere2 = "Query error: Unknown column 'asdsa' in 'where clause' (1054).";
39+
$errGroup2 = "Query error: Unknown column 'xy' in 'group statement' (1054).";
40+
41+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
42+
$errSelect = "Query error: Unknown column 'doesNotExist' in 'SELECT' (1054).";
43+
$errWhere = "Query error: Unknown column 'doesNotExist' in 'WHERE' (1054).";
44+
$errOrder = "Query error: Unknown column 'doesNotExist' in 'ORDER BY' (1054).";
45+
$errGroup = "Query error: Unknown column 'doesNotExist' in 'GROUP BY' (1054).";
46+
$errWhere2 = "Query error: Unknown column 'asdsa' in 'WHERE' (1054).";
47+
$errGroup2 = "Query error: Unknown column 'xy' in 'GROUP BY' (1054).";
48+
}
49+
3450
$expected = [
3551
[
3652
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
@@ -41,19 +57,19 @@ public function testSyntaxErrorInQueryRule(): void
4157
16,
4258
],
4359
[
44-
"Query error: Unknown column 'doesNotExist' in 'field list' (1054).",
60+
$errSelect,
4561
21,
4662
],
4763
[
48-
"Query error: Unknown column 'doesNotExist' in 'where clause' (1054).",
64+
$errWhere,
4965
26,
5066
],
5167
[
52-
"Query error: Unknown column 'doesNotExist' in 'order clause' (1054).",
68+
$errOrder,
5369
31,
5470
],
5571
[
56-
"Query error: Unknown column 'doesNotExist' in 'group statement' (1054).",
72+
$errGroup,
5773
36,
5874
],
5975
[
@@ -73,11 +89,11 @@ public function testSyntaxErrorInQueryRule(): void
7389
82,
7490
],
7591
[
76-
"Query error: Unknown column 'asdsa' in 'where clause' (1054).",
92+
$errWhere2,
7793
103,
7894
],
7995
[
80-
"Query error: Unknown column 'xy' in 'group statement' (1054).",
96+
$errGroup2,
8197
118,
8298
],
8399
[
@@ -98,6 +114,10 @@ public function testSyntaxErrorInQueryRule(): void
98114
],
99115
];
100116
} elseif (PdoMysqlQueryReflector::NAME === getenv('DBA_REFLECTOR')) {
117+
if ('mariadb' === $_ENV['DBA_PLATFORM']) {
118+
self::markTestSkipped("We don't test all variants of expectations for all drivers");
119+
}
120+
101121
$expected = [
102122
[
103123
"Query error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (42000).",

0 commit comments

Comments
 (0)