Skip to content

Commit 92a569a

Browse files
staabmclxmstaab
andauthored
support named placeholders in LIMIT clause (#101)
Co-authored-by: Markus Staab <[email protected]>
1 parent 9e12104 commit 92a569a

File tree

3 files changed

+86
-45
lines changed

3 files changed

+86
-45
lines changed

.phpstan-dba.cache

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
)),
213213
'result' =>
214214
array (
215-
1 => NULL,
216215
2 => NULL,
216+
1 => NULL,
217217
3 => NULL,
218218
),
219219
),
@@ -984,31 +984,27 @@
984984
'error' => NULL,
985985
'result' =>
986986
array (
987-
1 =>
987+
2 =>
988988
PHPStan\Type\Constant\ConstantArrayType::__set_state(array(
989989
'keyType' =>
990990
PHPStan\Type\UnionType::__set_state(array(
991991
'types' =>
992992
array (
993993
0 =>
994-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
995-
'value' => 'adaid',
996-
'isClassString' => false,
994+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
995+
'value' => 0,
997996
)),
998997
1 =>
999-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1000-
'value' => 'email',
1001-
'isClassString' => false,
998+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
999+
'value' => 1,
10021000
)),
10031001
2 =>
1004-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1005-
'value' => 'freigabe1u1',
1006-
'isClassString' => false,
1002+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1003+
'value' => 2,
10071004
)),
10081005
3 =>
1009-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1010-
'value' => 'gesperrt',
1011-
'isClassString' => false,
1006+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1007+
'value' => 3,
10121008
)),
10131009
),
10141010
)),
@@ -1030,24 +1026,20 @@
10301026
'keyTypes' =>
10311027
array (
10321028
0 =>
1033-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1034-
'value' => 'email',
1035-
'isClassString' => false,
1029+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1030+
'value' => 0,
10361031
)),
10371032
1 =>
1038-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1039-
'value' => 'adaid',
1040-
'isClassString' => false,
1033+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1034+
'value' => 1,
10411035
)),
10421036
2 =>
1043-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1044-
'value' => 'gesperrt',
1045-
'isClassString' => false,
1037+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1038+
'value' => 2,
10461039
)),
10471040
3 =>
1048-
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1049-
'value' => 'freigabe1u1',
1050-
'isClassString' => false,
1041+
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1042+
'value' => 3,
10511043
)),
10521044
),
10531045
'valueTypes' =>
@@ -1071,32 +1063,36 @@
10711063
'max' => 127,
10721064
)),
10731065
),
1074-
'nextAutoIndex' => 0,
1066+
'nextAutoIndex' => 4,
10751067
'optionalKeys' =>
10761068
array (
10771069
),
10781070
)),
1079-
2 =>
1071+
1 =>
10801072
PHPStan\Type\Constant\ConstantArrayType::__set_state(array(
10811073
'keyType' =>
10821074
PHPStan\Type\UnionType::__set_state(array(
10831075
'types' =>
10841076
array (
10851077
0 =>
1086-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1087-
'value' => 0,
1078+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1079+
'value' => 'adaid',
1080+
'isClassString' => false,
10881081
)),
10891082
1 =>
1090-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1091-
'value' => 1,
1083+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1084+
'value' => 'email',
1085+
'isClassString' => false,
10921086
)),
10931087
2 =>
1094-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1095-
'value' => 2,
1088+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1089+
'value' => 'freigabe1u1',
1090+
'isClassString' => false,
10961091
)),
10971092
3 =>
1098-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1099-
'value' => 3,
1093+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1094+
'value' => 'gesperrt',
1095+
'isClassString' => false,
11001096
)),
11011097
),
11021098
)),
@@ -1118,20 +1114,24 @@
11181114
'keyTypes' =>
11191115
array (
11201116
0 =>
1121-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1122-
'value' => 0,
1117+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1118+
'value' => 'email',
1119+
'isClassString' => false,
11231120
)),
11241121
1 =>
1125-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1126-
'value' => 1,
1122+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1123+
'value' => 'adaid',
1124+
'isClassString' => false,
11271125
)),
11281126
2 =>
1129-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1130-
'value' => 2,
1127+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1128+
'value' => 'gesperrt',
1129+
'isClassString' => false,
11311130
)),
11321131
3 =>
1133-
PHPStan\Type\Constant\ConstantIntegerType::__set_state(array(
1134-
'value' => 3,
1132+
PHPStan\Type\Constant\ConstantStringType::__set_state(array(
1133+
'value' => 'freigabe1u1',
1134+
'isClassString' => false,
11351135
)),
11361136
),
11371137
'valueTypes' =>
@@ -1155,7 +1155,7 @@
11551155
'max' => 127,
11561156
)),
11571157
),
1158-
'nextAutoIndex' => 4,
1158+
'nextAutoIndex' => 0,
11591159
'optionalKeys' =>
11601160
array (
11611161
),

.phpunit-phpstan-dba.cache

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
array (
3434
'error' => NULL,
3535
),
36+
'
37+
SELECT email, adaid
38+
FROM ada
39+
WHERE gesperrt = \'1\'
40+
LIMIT \'1\', \'1\'
41+
' =>
42+
array (
43+
'error' => NULL,
44+
),
3645
'
3746
SELECT email, adaid
3847
FROM ada
@@ -64,6 +73,24 @@
6473
'code' => 1064,
6574
)),
6675
),
76+
'
77+
SELECT email, adaid
78+
FROM ada
79+
WHERE gesperrt = \'1\'
80+
LIMIT \'1\'
81+
' =>
82+
array (
83+
'error' => NULL,
84+
),
85+
'
86+
SELECT email, adaid
87+
FROM ada
88+
WHERE gesperrt = \'1\'
89+
LIMIT \'1\', \'1\'
90+
' =>
91+
array (
92+
'error' => NULL,
93+
),
6794
'
6895
SELECT email, adaid
6996
FROM ada

tests/data/syntax-error-in-prepared-statement.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ public function noErrorOnPlaceholderInLimit(Connection $connection, int $limit)
5252
WHERE gesperrt = ?
5353
LIMIT ?
5454
', [1, $limit]);
55+
56+
$connection->preparedQuery('
57+
SELECT email, adaid
58+
FROM ada
59+
WHERE gesperrt = :gesperrt
60+
LIMIT :limit
61+
', [':gesperrt' => 1, ':limit' => $limit]);
5562
}
5663

5764
public function noErrorOnPlaceholderInOffsetAndLimit(Connection $connection, int $offset, int $limit)
@@ -62,6 +69,13 @@ public function noErrorOnPlaceholderInOffsetAndLimit(Connection $connection, int
6269
WHERE gesperrt = ?
6370
LIMIT ?, ?
6471
', [1, $offset, $limit]);
72+
73+
$connection->preparedQuery('
74+
SELECT email, adaid
75+
FROM ada
76+
WHERE gesperrt = :gesperrt
77+
LIMIT :offset, :limit
78+
', [':gesperrt' => 1, ':offset' => $offset, ':limit' => $limit]);
6579
}
6680

6781
public function preparedParams(Connection $connection)

0 commit comments

Comments
 (0)