diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index dd4a9fc12..c5dcbcbdc 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -124,9 +124,9 @@ public static function parse(Parser $parser, TokensList $list, array $options = $ret->values[] = trim($lastValue); $lastRaw = $lastValue = ''; } + continue; } - continue; } } diff --git a/tests/Parser/InsertStatementTest.php b/tests/Parser/InsertStatementTest.php index 3790d43cf..e0a40b27f 100644 --- a/tests/Parser/InsertStatementTest.php +++ b/tests/Parser/InsertStatementTest.php @@ -23,6 +23,7 @@ public function insertProvider(): array { return [ ['parser/parseInsert'], + ['parser/parseInsertFunction'], ['parser/parseInsertSelect'], ['parser/parseInsertOnDuplicateKey'], ['parser/parseInsertSetOnDuplicateKey'], diff --git a/tests/data/parser/parseInsertFunction.in b/tests/data/parser/parseInsertFunction.in new file mode 100644 index 000000000..5958daf08 --- /dev/null +++ b/tests/data/parser/parseInsertFunction.in @@ -0,0 +1,2 @@ +INSERT INTO labels(`label`) +VALUES (concat('A', ' ', 'label')); \ No newline at end of file diff --git a/tests/data/parser/parseInsertFunction.out b/tests/data/parser/parseInsertFunction.out new file mode 100644 index 000000000..9c941a844 --- /dev/null +++ b/tests/data/parser/parseInsertFunction.out @@ -0,0 +1,305 @@ +{ + "query": "INSERT INTO labels(`label`)\nVALUES (concat('A', ' ', 'label'));", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "INSERT INTO labels(`label`)\nVALUES (concat('A', ' ', 'label'));", + "len": 63, + "last": 63, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INSERT", + "value": "INSERT", + "keyword": "INSERT", + "type": 1, + "flags": 35, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "INTO", + "value": "INTO", + "keyword": "INTO", + "type": 1, + "flags": 3, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "labels", + "value": "labels", + "keyword": null, + "type": 0, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 18 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "`label`", + "value": "label", + "keyword": null, + "type": 8, + "flags": 2, + "position": 19 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 26 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "VALUES", + "value": "VALUES", + "keyword": "VALUES", + "type": 1, + "flags": 35, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 34 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 35 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "concat", + "value": "concat", + "keyword": "CONCAT", + "type": 1, + "flags": 33, + "position": 36 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "(", + "value": "(", + "keyword": null, + "type": 2, + "flags": 16, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "'A'", + "value": "A", + "keyword": null, + "type": 7, + "flags": 1, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 46 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 47 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "' '", + "value": " ", + "keyword": null, + "type": 7, + "flags": 1, + "position": 48 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ",", + "value": ",", + "keyword": null, + "type": 2, + "flags": 16, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "'label'", + "value": "label", + "keyword": null, + "type": 7, + "flags": 1, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 60 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ")", + "value": ")", + "keyword": null, + "type": 2, + "flags": 16, + "position": 61 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": ";", + "value": ";", + "keyword": null, + "type": 9, + "flags": 0, + "position": 62 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 25, + "idx": 25 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": { + "@type": "PhpMyAdmin\\SqlParser\\Parser", + "list": { + "@type": "@1" + }, + "statements": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Statements\\InsertStatement", + "into": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\IntoKeyword", + "type": null, + "dest": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\Expression", + "database": null, + "table": "labels", + "column": null, + "expr": "labels", + "alias": null, + "function": null, + "subquery": null + }, + "columns": [ + "label" + ], + "values": null, + "fields_options": null, + "fields_keyword": null, + "lines_options": null + }, + "values": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Components\\ArrayObj", + "raw": [ + "concat('A', ' ', 'label')" + ], + "values": [ + "concat(A, , label)" + ] + } + ], + "set": null, + "select": null, + "with": null, + "onDuplicateSet": null, + "options": { + "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray", + "options": [] + }, + "first": 0, + "last": 22 + } + ], + "brackets": 0, + "strict": false, + "errors": [] + }, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file