Skip to content

Commit 7c11d3f

Browse files
committed
Fix #236 - "enclosed by" is not recognized by the parser
Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent 44a4aec commit 7c11d3f

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

src/Components/IntoKeyword.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ public static function parse(Parser $parser, TokensList $list, array $options =
223223

224224
$state = 3;
225225
} elseif ($state === 3) {
226-
$ret->parseFileOptions($parser, $list, $token->value);
226+
$ret->parseFileOptions($parser, $list, $token->keyword);
227227
$state = 4;
228228
} elseif ($state === 4) {
229229
if ($token->type === Token::TYPE_KEYWORD && $token->keyword !== 'LINES') {
230230
break;
231231
}
232232

233-
$ret->parseFileOptions($parser, $list, $token->value);
233+
$ret->parseFileOptions($parser, $list, $token->keyword);
234234
$state = 5;
235235
}
236236
}
@@ -243,7 +243,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
243243
/**
244244
* @param Parser $parser The parser
245245
* @param TokensList $list A token list
246-
* @param string $keyword They keyword
246+
* @param string $keyword The keyword
247247
*
248248
* @return void
249249
*/

tests/data/parser/parseLoad7.out

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,10 @@
316316
"dest": "/tmp/temp.data",
317317
"columns": null,
318318
"values": null,
319-
"fields_options": null,
320-
"fields_keyword": null,
321-
"lines_options": {
319+
"fields_options": {
322320
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
323321
"options": {
324-
"2": {
322+
"1": {
325323
"name": "TERMINATED BY",
326324
"equals": false,
327325
"expr": {
@@ -335,9 +333,41 @@
335333
"subquery": null
336334
},
337335
"value": "','"
336+
},
337+
"3": {
338+
"name": "ENCLOSED BY",
339+
"equals": false,
340+
"expr": {
341+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
342+
"database": null,
343+
"table": null,
344+
"column": "\"",
345+
"expr": "'\"'",
346+
"alias": null,
347+
"function": null,
348+
"subquery": null
349+
},
350+
"value": "'\"'"
351+
},
352+
"4": {
353+
"name": "ESCAPED BY",
354+
"equals": false,
355+
"expr": {
356+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
357+
"database": null,
358+
"table": null,
359+
"column": "$",
360+
"expr": "'$'",
361+
"alias": null,
362+
"function": null,
363+
"subquery": null
364+
},
365+
"value": "'$'"
338366
}
339367
}
340-
}
368+
},
369+
"fields_keyword": true,
370+
"lines_options": null
341371
},
342372
"join": null,
343373
"union": [],
@@ -356,35 +386,6 @@
356386
},
357387
"errors": {
358388
"lexer": [],
359-
"parser": [
360-
[
361-
"Unrecognized keyword.",
362-
{
363-
"@type": "@18"
364-
},
365-
0
366-
],
367-
[
368-
"Unexpected token.",
369-
{
370-
"@type": "@20"
371-
},
372-
0
373-
],
374-
[
375-
"Unrecognized keyword.",
376-
{
377-
"@type": "@22"
378-
},
379-
0
380-
],
381-
[
382-
"Unexpected token.",
383-
{
384-
"@type": "@24"
385-
},
386-
0
387-
]
388-
]
389+
"parser": []
389390
}
390391
}

0 commit comments

Comments
 (0)