Skip to content

Commit c571579

Browse files
committed
Merge branch 'master' into 6.0.x
Signed-off-by: William Desportes <[email protected]>
2 parents a028de5 + ff593ee commit c571579

File tree

13 files changed

+57
-74
lines changed

13 files changed

+57
-74
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Add missing return types annotations
66
* Improve the WITH statements parser (#363)
77
* Add support for passing `Context::SQL_MODE*` constants to `Context::setMode` method
8+
* Fix additional body tokens issue with `CREATE VIEW` statements (#371)
89

910
## [5.5.0] - 2021-12-08
1011

locale/fr/LC_MESSAGES/sqlparser.mo

286 Bytes
Binary file not shown.

locale/fr/LC_MESSAGES/sqlparser.po

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ msgstr ""
44
"Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n"
55
"Report-Msgid-Bugs-To: [email protected]\n"
66
"POT-Creation-Date: 2021-12-29 16:13-0300\n"
7-
"PO-Revision-Date: 2020-03-20 20:58+0000\n"
7+
"PO-Revision-Date: 2022-02-17 09:56+0000\n"
88
"Last-Translator: William Desportes <[email protected]>\n"
9-
"Language-Team: French <https://hosted.weblate.org/projects/phpmyadmin/sql-"
10-
"parser/fr/>\n"
9+
"Language-Team: French <https://hosted.weblate.org/projects/phpmyadmin/"
10+
"sql-parser/fr/>\n"
1111
"Language: fr\n"
1212
"MIME-Version: 1.0\n"
1313
"Content-Type: text/plain; charset=UTF-8\n"
1414
"Content-Transfer-Encoding: 8bit\n"
1515
"Plural-Forms: nplurals=2; plural=n > 1;\n"
16-
"X-Generator: Weblate 4.0-dev\n"
16+
"X-Generator: Weblate 4.11-dev\n"
1717

1818
#: src/Component.php:42 src/Component.php:62
1919
msgid "Not implemented yet."
@@ -41,7 +41,7 @@ msgstr "%1$d valeurs étaient attendues, mais %2$d ont été trouvées."
4141

4242
#: src/Components/Array2d.php:111
4343
msgid "An opening bracket followed by a set of values was expected."
44-
msgstr "Une parenthèse gauche suivie d'un ensemble de valeurs était attendus."
44+
msgstr "Une parenthèse gauche suivie d'un ensemble de valeurs étaient attendus."
4545

4646
#: src/Components/ArrayObj.php:109 src/Components/CreateDefinition.php:232
4747
msgid "An opening bracket was expected."
@@ -251,28 +251,20 @@ msgid "Unexpected keyword"
251251
msgstr "Mot clef inattendu"
252252

253253
#: src/Statements/WithStatement.php:119
254-
#, fuzzy
255-
#| msgid "The name of the entity was expected."
256254
msgid "The name of the CTE was expected."
257-
msgstr "Le nom de l'entité était attendu."
255+
msgstr "Le nom du CTE était attendu."
258256

259257
#: src/Statements/WithStatement.php:138
260-
#, fuzzy
261-
#| msgid "A \"RETURNS\" keyword was expected."
262258
msgid "AS keyword was expected."
263-
msgstr "Le mot clé « RETURNS » était attendu."
259+
msgstr "Le mot clé AS était attendu."
264260

265261
#: src/Statements/WithStatement.php:154
266-
#, fuzzy
267-
#| msgid "The name of the entity was expected."
268262
msgid "Subquery of the CTE was expected."
269-
msgstr "Le nom de l'entité était attendu."
263+
msgstr "Une sous-requête du CTE était attendue."
270264

271265
#: src/Statements/WithStatement.php:271
272-
#, fuzzy
273-
#| msgid "Unexpected end of LOCK statement."
274266
msgid "Unexpected end of the WITH CTE."
275-
msgstr "Fin inattendue de l'instruction LOCK."
267+
msgstr "Fin inattendue du WITH CTE."
276268

277269
#~ msgid "error #1"
278270
#~ msgstr "erreur #1"

locale/ro/LC_MESSAGES/sqlparser.mo

804 Bytes
Binary file not shown.

locale/ro/LC_MESSAGES/sqlparser.po

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ msgstr ""
44
"Project-Id-Version: SQL parser 5\n"
55
"Report-Msgid-Bugs-To: [email protected]\n"
66
"POT-Creation-Date: 2021-12-29 16:13-0300\n"
7-
"PO-Revision-Date: 2018-07-24 05:41+0000\n"
8-
"Last-Translator: Dan Caragea <dan_caragea@yahoo.com>\n"
9-
"Language-Team: Romanian <https://hosted.weblate.org/projects/phpmyadmin/sql-"
10-
"parser/ro/>\n"
7+
"PO-Revision-Date: 2022-02-08 00:58+0000\n"
8+
"Last-Translator: liviuconcioiu <liviu.concioiu@gmail.com>\n"
9+
"Language-Team: Romanian <https://hosted.weblate.org/projects/phpmyadmin/"
10+
"sql-parser/ro/>\n"
1111
"Language: ro\n"
1212
"MIME-Version: 1.0\n"
1313
"Content-Type: text/plain; charset=UTF-8\n"
1414
"Content-Transfer-Encoding: 8bit\n"
1515
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < "
1616
"20)) ? 1 : 2;\n"
17-
"X-Generator: Weblate 3.1-dev\n"
17+
"X-Generator: Weblate 4.11-dev\n"
1818

1919
#: src/Component.php:42 src/Component.php:62
2020
msgid "Not implemented yet."
@@ -67,28 +67,24 @@ msgstr "Cuvinte cheie neașteptate."
6767

6868
#: src/Components/CaseExpression.php:195
6969
msgid "Unexpected end of CASE expression"
70-
msgstr "Sirsit neasteptat al expresiei \"CASE\""
70+
msgstr "Sfârșit neașteptat al expresiei CASE"
7171

7272
#: src/Components/CaseExpression.php:215
73-
#, fuzzy
74-
#| msgid "Unexpected end of CASE expression"
7573
msgid "Potential duplicate alias of CASE expression."
76-
msgstr "Sirsit neasteptat al expresiei \"CASE\""
74+
msgstr "Alias potențial duplicat al expresiei CASE."
7775

7876
#: src/Components/CaseExpression.php:228
7977
msgid "An alias expected after AS but got "
80-
msgstr ""
78+
msgstr "Era așteptat un alias după AS dar am primit "
8179

8280
#: src/Components/CaseExpression.php:241 src/Components/Expression.php:353
8381
#: src/Components/Expression.php:373 src/Components/Expression.php:408
8482
msgid "An alias was previously found."
8583
msgstr "A fost găsit anterior un alias."
8684

8785
#: src/Components/CaseExpression.php:255
88-
#, fuzzy
89-
#| msgid "An alias was expected."
9086
msgid "An alias was expected after AS."
91-
msgstr "Era așteptat un alias."
87+
msgstr "Era așteptat un alias după AS."
9288

9389
#: src/Components/CreateDefinition.php:254
9490
msgid ""
@@ -146,16 +142,12 @@ msgid "An offset was expected."
146142
msgstr "Era așteptat un decalaj."
147143

148144
#: src/Components/LockExpression.php:94
149-
#, fuzzy
150-
#| msgid "Unexpected end of CASE expression"
151145
msgid "Unexpected end of LOCK expression."
152-
msgstr "Sirsit neasteptat al expresiei \"CASE\""
146+
msgstr "Sfârșit neașteptat al expresiei LOCK."
153147

154148
#: src/Components/LockExpression.php:204
155-
#, fuzzy
156-
#| msgid "Unexpected end of CASE expression"
157149
msgid "Unexpected end of Lock expression."
158-
msgstr "Sirsit neasteptat al expresiei \"CASE\""
150+
msgstr "Sfârșit neașteptat al expresiei LOCK."
159151

160152
#: src/Components/OptionsArray.php:151
161153
#, php-format
@@ -252,28 +244,20 @@ msgid "This type of clause is not valid in Multi-table queries."
252244
msgstr "Acest tip de clauză nu este valid în interogările mai multor tabele."
253245

254246
#: src/Statements/LockStatement.php:123
255-
#, fuzzy
256-
#| msgid "Unexpected beginning of statement."
257247
msgid "Unexpected end of LOCK statement."
258-
msgstr "Început neașteptat al declarației."
248+
msgstr "Sfârșit neașteptat al declarației LOCK."
259249

260250
#: src/Statements/PurgeStatement.php:141
261-
#, fuzzy
262-
#| msgid "Unexpected keyword."
263251
msgid "Unexpected keyword"
264-
msgstr "Cuvinte cheie neașteptate."
252+
msgstr "Cuvânt-cheie neașteptat"
265253

266254
#: src/Statements/WithStatement.php:119
267-
#, fuzzy
268-
#| msgid "The name of the entity was expected."
269255
msgid "The name of the CTE was expected."
270-
msgstr "Era așteptat numele entității."
256+
msgstr "Era așteptat numele CTE."
271257

272258
#: src/Statements/WithStatement.php:138
273-
#, fuzzy
274-
#| msgid "A \"RETURNS\" keyword was expected."
275259
msgid "AS keyword was expected."
276-
msgstr "Un cuvânt cheie \"RETURNS\" era de aşteptat."
260+
msgstr "Era de aşteptat cuvântul-cheie AS."
277261

278262
#: src/Statements/WithStatement.php:154
279263
#, fuzzy

src/Statements/CreateStatement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ public function parse(Parser $parser, TokensList $list)
746746
if ($list->tokens[$nextidx]->value === 'SELECT') {
747747
$list->idx = $nextidx;
748748
$this->select = new SelectStatement($parser, $list);
749+
++$list->idx; // Skipping last token from the select.
749750
} elseif ($list->tokens[$nextidx]->value === 'WITH') {
750751
++$list->idx;
751752
$this->with = new WithStatement($parser, $list);

tests/Builder/CreateStatementTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,33 @@ public function testBuilderView(): void
342342
'SELECT id, first_name, FROMzz employee WHERE id = 2 ',
343343
$stmt->build()
344344
);
345+
346+
$parser = new Parser('CREATE VIEW `view_programlevelpartner` AS SELECT `p`.`country_id`'
347+
. 'AS `country_id` FROM `program_level_partner` `p` ORDER BY `p`.`id` asc');
348+
$stmt = $parser->statements[0];
349+
$this->assertEquals(
350+
'CREATE VIEW `view_programlevelpartner` AS SELECT `p`.`country_id`'
351+
. ' AS `country_id` FROM `program_level_partner` AS `p` ORDER BY `p`.`id` ASC ',
352+
$stmt->build()
353+
);
354+
355+
$parser = new Parser('CREATE VIEW `view_zg_bycountry` AS '
356+
. 'SELECT `d`.`zg_id` FROM `view_zg_value` AS `d` GROUP BY `d`.`ind_id`;');
357+
$stmt = $parser->statements[0];
358+
$this->assertEquals(
359+
'CREATE VIEW `view_zg_bycountry` AS '
360+
. 'SELECT `d`.`zg_id` FROM `view_zg_value` AS `d` GROUP BY `d`.`ind_id` ',
361+
$stmt->build()
362+
);
363+
364+
$parser = new Parser('CREATE view view_name AS WITH aa(col1)'
365+
. ' AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte AS `d` ');
366+
$stmt = $parser->statements[0];
367+
$this->assertEquals(
368+
'CREATE view view_name AS WITH aa(col1)'
369+
. ' AS (SELECT 1 UNION ALL SELECT 2) SELECT col1 FROM cte AS `d` ',
370+
$stmt->build()
371+
);
345372
}
346373

347374
public function testBuilderViewComplex(): void

tests/data/parser/parseCreateView.out

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,11 +3534,7 @@
35343534
"table": null,
35353535
"return": null,
35363536
"parameters": null,
3537-
"body": [
3538-
{
3539-
"@type": "@286"
3540-
}
3541-
],
3537+
"body": [],
35423538
"clauses": [],
35433539
"statementEndOptions": [],
35443540
"options": {

tests/data/parser/parseCreateView3.out

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,9 +1171,6 @@
11711171
"return": null,
11721172
"parameters": null,
11731173
"body": [
1174-
{
1175-
"@type": "@28"
1176-
},
11771174
{
11781175
"@type": "@29"
11791176
},

tests/data/parser/parseCreateViewWithQuotes.out

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,7 @@
12231223
"table": null,
12241224
"return": null,
12251225
"parameters": null,
1226-
"body": [
1227-
{
1228-
"@type": "@43"
1229-
}
1230-
],
1226+
"body": [],
12311227
"clauses": [],
12321228
"statementEndOptions": [],
12331229
"options": {

0 commit comments

Comments
 (0)