Skip to content

Commit 8e48df3

Browse files
committed
Merge #420 - Provide new unit test + fix with ALTER EVENT RENAME TO using expression
Pull-request: #420 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents 7315fc9 + b95fed9 commit 8e48df3

File tree

6 files changed

+1306
-11
lines changed

6 files changed

+1306
-11
lines changed

src/Components/AlterOperation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ class AlterOperation extends Component
217217
'RENAME' => 6,
218218
'TO' => [
219219
7,
220-
'var',
220+
'expr',
221+
['parseField' => 'table'],
221222
],
222223
'ENABLE' => 8,
223224
'DISABLE' => 8,

tests/Parser/AlterStatementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function alterProvider(): array
6565
['parser/parseAlterEvent6'],
6666
['parser/parseAlterEvent7'],
6767
['parser/parseAlterEvent8'],
68+
['parser/parseAlterEvent9'],
6869
['parser/parseAlterEventComplete'],
6970
['parser/parseAlterEventErr'],
7071
['parser/parseAlterEventOnScheduleAt'],

tests/data/parser/parseAlterEvent6.out

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@
582582
"COLUMN": 2,
583583
"CONSTRAINT": 2,
584584
"DEFAULT": 2,
585-
"TO": 2,
586585
"BY": 2,
587586
"FOREIGN": 2,
588587
"FULLTEXT": 2,
@@ -594,8 +593,15 @@
594593
"PRIMARY KEY": 2,
595594
"SPATIAL": 2,
596595
"TABLESPACE": 2,
597-
"INDEX": 2,
598-
"CHARACTER SET": 3
596+
"INDEX": [
597+
2,
598+
"var"
599+
],
600+
"CHARACTER SET": 3,
601+
"TO": [
602+
3,
603+
"var"
604+
]
599605
},
600606
"USER_OPTIONS": {
601607
"ATTRIBUTE": [
@@ -654,7 +660,10 @@
654660
"RENAME": 6,
655661
"TO": [
656662
7,
657-
"var"
663+
"expr",
664+
{
665+
"parseField": "table"
666+
}
658667
],
659668
"ENABLE": 8,
660669
"DISABLE": 8,
@@ -672,7 +681,34 @@
672681
"7": {
673682
"name": "TO",
674683
"equals": false,
675-
"expr": "my_new_event",
684+
"expr": {
685+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
686+
"ALLOWED_KEYWORDS": {
687+
"AND": 1,
688+
"AS": 1,
689+
"BETWEEN": 1,
690+
"CASE": 1,
691+
"DUAL": 1,
692+
"DIV": 1,
693+
"IS": 1,
694+
"MOD": 1,
695+
"NOT": 1,
696+
"NOT NULL": 1,
697+
"NULL": 1,
698+
"OR": 1,
699+
"OVER": 1,
700+
"REGEXP": 1,
701+
"RLIKE": 1,
702+
"XOR": 1
703+
},
704+
"database": null,
705+
"table": "my_new_event",
706+
"column": null,
707+
"expr": "my_new_event",
708+
"alias": null,
709+
"function": null,
710+
"subquery": null
711+
},
676712
"value": "my_new_event"
677713
}
678714
}

tests/data/parser/parseAlterEvent9.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER EVENT old_db.old_event RENAME TO new_db.new_event;
2+
ALTER EVENT `old_db`.`old_event` RENAME TO `new_db`.`new_event`;

0 commit comments

Comments
 (0)