Skip to content

Commit 448ef57

Browse files
committed
Add tests for MariaDB comment /*M!
Signed-off-by: Maximilian Krög <maximilian.kroeg@geocept.com>
1 parent 5303ac8 commit 448ef57

6 files changed

Lines changed: 319 additions & 13 deletions

File tree

tests/Lexer/IsMethodsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public function testIsComment(): void
6161
{
6262
$this->assertEquals(Token::FLAG_COMMENT_BASH, Context::isComment('#'));
6363
$this->assertEquals(Token::FLAG_COMMENT_C, Context::isComment('/*'));
64+
$this->assertEquals(Token::FLAG_COMMENT_MYSQL_CMD, Context::isComment('/*!'));
65+
$this->assertEquals(Token::FLAG_COMMENT_MYSQL_CMD, Context::isComment('/*!50000'));
6466
$this->assertEquals(Token::FLAG_COMMENT_C, Context::isComment('*/'));
6567
$this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment('-- '));
6668
$this->assertEquals(Token::FLAG_COMMENT_SQL, Context::isComment("--\t"));

tests/Parser/CreateStatementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static function createProvider(): array
6060
['parser/parseCreateTableErr5'],
6161
['parser/parseCreateTableSelect'],
6262
['parser/parseCreateTableAsSelect'],
63+
['parser/parseCreateTableColumnCompressed'],
6364
['parser/parseCreateTableLike'],
6465
['parser/parseCreateTableSpatial'],
6566
['parser/parseCreateTableSRID'],

tests/data/lexer/lexComment.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# comment
2-
SELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2 /* select query */
2+
SELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2; /* select query */
33
-- comment
4-
-- comment 2
4+
-- comment 2
5+
SELECT /*M!100300 1, */ 2;

tests/data/lexer/lexComment.out

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"query": "# comment\nSELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2 /* select query */\n-- comment\n-- comment 2",
2+
"query": "# comment\nSELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2; /* select query */\n-- comment\n-- comment 2\nSELECT /*M!100300 1, */ 2;",
33
"lexer": {
44
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5-
"str": "# comment\nSELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2 /* select query */\n-- comment\n-- comment 2",
6-
"len": 110,
7-
"last": 111,
5+
"str": "# comment\nSELECT /*!50000 STRAIGHT_JOIN */ col1 FROM table1, table2; /* select query */\n-- comment\n-- comment 2\nSELECT /*M!100300 1, */ 2;",
6+
"len": 138,
7+
"last": 138,
88
"list": {
99
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
1010
"tokens": [
@@ -170,14 +170,23 @@
170170
"flags": 0,
171171
"position": 61
172172
},
173+
{
174+
"@type": "PhpMyAdmin\\SqlParser\\Token",
175+
"token": ";",
176+
"value": ";",
177+
"keyword": null,
178+
"type": 9,
179+
"flags": 0,
180+
"position": 67
181+
},
173182
{
174183
"@type": "PhpMyAdmin\\SqlParser\\Token",
175184
"token": " ",
176185
"value": " ",
177186
"keyword": null,
178187
"type": 3,
179188
"flags": 0,
180-
"position": 67
189+
"position": 68
181190
},
182191
{
183192
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -186,7 +195,7 @@
186195
"keyword": null,
187196
"type": 4,
188197
"flags": 2,
189-
"position": 68
198+
"position": 69
190199
},
191200
{
192201
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -195,7 +204,7 @@
195204
"keyword": null,
196205
"type": 3,
197206
"flags": 0,
198-
"position": 86
207+
"position": 87
199208
},
200209
{
201210
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -204,7 +213,7 @@
204213
"keyword": null,
205214
"type": 4,
206215
"flags": 4,
207-
"position": 87
216+
"position": 88
208217
},
209218
{
210219
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -213,7 +222,7 @@
213222
"keyword": null,
214223
"type": 3,
215224
"flags": 0,
216-
"position": 97
225+
"position": 98
217226
},
218227
{
219228
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -222,7 +231,70 @@
222231
"keyword": null,
223232
"type": 4,
224233
"flags": 4,
225-
"position": 98
234+
"position": 99
235+
},
236+
{
237+
"@type": "PhpMyAdmin\\SqlParser\\Token",
238+
"token": "\n",
239+
"value": " ",
240+
"keyword": null,
241+
"type": 3,
242+
"flags": 0,
243+
"position": 111
244+
},
245+
{
246+
"@type": "PhpMyAdmin\\SqlParser\\Token",
247+
"token": "SELECT",
248+
"value": "SELECT",
249+
"keyword": "SELECT",
250+
"type": 1,
251+
"flags": 3,
252+
"position": 112
253+
},
254+
{
255+
"@type": "PhpMyAdmin\\SqlParser\\Token",
256+
"token": " ",
257+
"value": " ",
258+
"keyword": null,
259+
"type": 3,
260+
"flags": 0,
261+
"position": 118
262+
},
263+
{
264+
"@type": "PhpMyAdmin\\SqlParser\\Token",
265+
"token": "/*M!100300 1, */",
266+
"value": "/*M!100300 1, */",
267+
"keyword": null,
268+
"type": 4,
269+
"flags": 2,
270+
"position": 119
271+
},
272+
{
273+
"@type": "PhpMyAdmin\\SqlParser\\Token",
274+
"token": " ",
275+
"value": " ",
276+
"keyword": null,
277+
"type": 3,
278+
"flags": 0,
279+
"position": 135
280+
},
281+
{
282+
"@type": "PhpMyAdmin\\SqlParser\\Token",
283+
"token": "2",
284+
"value": 2,
285+
"keyword": null,
286+
"type": 6,
287+
"flags": 0,
288+
"position": 136
289+
},
290+
{
291+
"@type": "PhpMyAdmin\\SqlParser\\Token",
292+
"token": ";",
293+
"value": ";",
294+
"keyword": null,
295+
"type": 9,
296+
"flags": 0,
297+
"position": 137
226298
},
227299
{
228300
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -234,7 +306,7 @@
234306
"position": null
235307
}
236308
],
237-
"count": 25,
309+
"count": 33,
238310
"idx": 0
239311
},
240312
"delimiter": ";",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE `t` (`c1` longtext /*M!100301 COMPRESSED*/);

0 commit comments

Comments
 (0)