Skip to content

Commit 2a9ee14

Browse files
staabmclxmstaab
andauthored
added mariadb coverage to github actions (#84)
Co-authored-by: Markus Staab <[email protected]>
1 parent cc55129 commit 2a9ee14

File tree

8 files changed

+32
-23
lines changed

8 files changed

+32
-23
lines changed

.github/workflows/phpstan.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
db-image: 'mysql:8.0'
2121
- php-version: "8.1"
2222
db-image: 'mysql:8.0'
23+
- php-version: '8.1'
24+
db-image: 'mariadb:latest'
2325

2426
# https://docs.github.com/en/free-pro-team@latest/actions/guides/about-service-containers
2527
services:

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
db-image: 'mysql:8.0'
2121
- php-version: "8.1"
2222
db-image: 'mysql:8.0'
23+
- php-version: '8.1'
24+
db-image: 'mariadb:latest'
2325

2426
# https://docs.github.com/en/free-pro-team@latest/actions/guides/about-service-containers
2527
services:

.phpstan-dba.cache

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
array (
208208
'error' =>
209209
staabm\PHPStanDba\Error::__set_state(array(
210-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1',
210+
'message' => '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',
211211
'code' => 1064,
212212
)),
213213
'result' =>
@@ -620,7 +620,7 @@
620620
array (
621621
'error' =>
622622
staabm\PHPStanDba\Error::__set_state(array(
623-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':email LIMIT 0\' at line 1',
623+
'message' => '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 \':email LIMIT 0\' at line 1',
624624
'code' => 1064,
625625
)),
626626
'result' =>
@@ -632,7 +632,7 @@
632632
array (
633633
'error' =>
634634
staabm\PHPStanDba\Error::__set_state(array(
635-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'? LIMIT 0\' at line 1',
635+
'message' => '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 \'? LIMIT 0\' at line 1',
636636
'code' => 1064,
637637
)),
638638
'result' =>
@@ -644,7 +644,7 @@
644644
array (
645645
'error' =>
646646
staabm\PHPStanDba\Error::__set_state(array(
647-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':adaid LIMIT 0\' at line 1',
647+
'message' => '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 \':adaid LIMIT 0\' at line 1',
648648
'code' => 1064,
649649
)),
650650
'result' =>
@@ -656,7 +656,7 @@
656656
array (
657657
'error' =>
658658
staabm\PHPStanDba\Error::__set_state(array(
659-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':adaid and email = \'[email protected]\' LIMIT 0\' at line 1',
659+
'message' => '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 \':adaid and email = \'[email protected]\' LIMIT 0\' at line 1',
660660
'code' => 1064,
661661
)),
662662
'result' =>
@@ -668,7 +668,7 @@
668668
array (
669669
'error' =>
670670
staabm\PHPStanDba\Error::__set_state(array(
671-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':adaid and email = :email LIMIT 0\' at line 1',
671+
'message' => '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 \':adaid and email = :email LIMIT 0\' at line 1',
672672
'code' => 1064,
673673
)),
674674
'result' =>
@@ -680,7 +680,7 @@
680680
array (
681681
'error' =>
682682
staabm\PHPStanDba\Error::__set_state(array(
683-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'? LIMIT 0\' at line 1',
683+
'message' => '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 \'? LIMIT 0\' at line 1',
684684
'code' => 1064,
685685
)),
686686
'result' =>
@@ -692,7 +692,7 @@
692692
array (
693693
'error' =>
694694
staabm\PHPStanDba\Error::__set_state(array(
695-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'? and email = ? LIMIT 0\' at line 1',
695+
'message' => '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 \'? and email = ? LIMIT 0\' at line 1',
696696
'code' => 1064,
697697
)),
698698
'result' =>
@@ -773,7 +773,7 @@
773773
array (
774774
'error' =>
775775
staabm\PHPStanDba\Error::__set_state(array(
776-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':email LIMIT 0\' at line 1',
776+
'message' => '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 \':email LIMIT 0\' at line 1',
777777
'code' => 1064,
778778
)),
779779
'result' =>
@@ -971,7 +971,7 @@
971971
array (
972972
'error' =>
973973
staabm\PHPStanDba\Error::__set_state(array(
974-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':email LIMIT 0\' at line 1',
974+
'message' => '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 \':email LIMIT 0\' at line 1',
975975
'code' => 1064,
976976
)),
977977
'result' =>

.phpunit-phpstan-dba.cache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
array (
197197
'error' =>
198198
staabm\PHPStanDba\Error::__set_state(array(
199-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'freigabe1u1 FROM ada LIMIT 0\' at line 1',
199+
'message' => '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',
200200
'code' => 1064,
201201
)),
202202
'result' =>
@@ -607,7 +607,7 @@
607607
array (
608608
'error' =>
609609
staabm\PHPStanDba\Error::__set_state(array(
610-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':adaid LIMIT 0\' at line 1',
610+
'message' => '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 \':adaid LIMIT 0\' at line 1',
611611
'code' => 1064,
612612
)),
613613
'result' =>
@@ -619,7 +619,7 @@
619619
array (
620620
'error' =>
621621
staabm\PHPStanDba\Error::__set_state(array(
622-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'? LIMIT 0\' at line 1',
622+
'message' => '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 \'? LIMIT 0\' at line 1',
623623
'code' => 1064,
624624
)),
625625
'result' =>
@@ -631,7 +631,7 @@
631631
array (
632632
'error' =>
633633
staabm\PHPStanDba\Error::__set_state(array(
634-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'? and email = ? LIMIT 0\' at line 1',
634+
'message' => '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 \'? and email = ? LIMIT 0\' at line 1',
635635
'code' => 1064,
636636
)),
637637
'result' =>
@@ -712,7 +712,7 @@
712712
array (
713713
'error' =>
714714
staabm\PHPStanDba\Error::__set_state(array(
715-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':email LIMIT 0\' at line 1',
715+
'message' => '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 \':email LIMIT 0\' at line 1',
716716
'code' => 1064,
717717
)),
718718
'result' =>
@@ -910,7 +910,7 @@
910910
array (
911911
'error' =>
912912
staabm\PHPStanDba\Error::__set_state(array(
913-
'message' => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \':email LIMIT 0\' at line 1',
913+
'message' => '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 \':email LIMIT 0\' at line 1',
914914
'code' => 1064,
915915
)),
916916
'result' =>

src/QueryReflection/MysqliQueryReflector.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ public function validateQueryString(string $queryString): ?Error
7676
return null;
7777
} catch (mysqli_sql_exception $e) {
7878
if (\in_array($e->getCode(), [self::MYSQL_SYNTAX_ERROR_CODE, self::MYSQL_UNKNOWN_COLUMN_IN_FIELDLIST, self::MYSQL_UNKNOWN_TABLE], true)) {
79-
return new Error($e->getMessage(), $e->getCode());
79+
// make error string consistent across mysql/mariadb
80+
$message = $e->getMessage();
81+
$message = str_replace(' MySQL server', ' MySQL/MariaDB server', $message);
82+
$message = str_replace(' MariaDB server', ' MySQL/MariaDB server', $message);
83+
84+
return new Error($message, $e->getCode());
8085
}
8186

8287
return null;

tests/SyntaxErrorInPreparedStatementMethodRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testSyntaxErrorInQueryRule(): void
2222

2323
$this->analyse([__DIR__.'/data/syntax-error-in-prepared-statement.php'], [
2424
[
25-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
25+
"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).",
2626
11,
2727
],
2828
]);

tests/SyntaxErrorInQueryFunctionRuleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function testSyntaxErrorInQueryRule(): void
2222

2323
$this->analyse([__DIR__.'/data/syntax-error-in-query-function.php'], [
2424
[
25-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
25+
"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).",
2626
11,
2727
],
2828
[
29-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
29+
"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).",
3030
21,
3131
],
3232
]);

tests/SyntaxErrorInQueryMethodRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function testSyntaxErrorInQueryRule(): void
2222

2323
$this->analyse([__DIR__.'/data/syntax-error-in-query.php'], [
2424
[
25-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
25+
"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).",
2626
11,
2727
],
2828
[
29-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
29+
"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).",
3030
16,
3131
],
3232
[
@@ -50,7 +50,7 @@ public function testSyntaxErrorInQueryRule(): void
5050
41,
5151
],
5252
[
53-
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
53+
"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).",
5454
67,
5555
],
5656
]);

0 commit comments

Comments
 (0)