@@ -21,6 +21,37 @@ public function testBuilder(): void
21
21
$ this ->assertEquals ($ query , $ stmt ->build ());
22
22
}
23
23
24
+ public function testBuilderWithComments (): void
25
+ {
26
+ $ query = 'ALTER /* comment */ TABLE `actor` ' .
27
+ 'ADD PRIMARY KEY (`actor_id`), -- comment at the end of the line ' . "\n" .
28
+ 'ADD KEY `idx_actor_last_name` (`last_name`) -- and that is the last comment. ' ;
29
+
30
+ $ expectedQuery = 'ALTER TABLE `actor` ' .
31
+ 'ADD PRIMARY KEY (`actor_id`), ' .
32
+ 'ADD KEY `idx_actor_last_name` (`last_name`) ' ;
33
+
34
+ $ parser = new Parser ($ query );
35
+ $ stmt = $ parser ->statements [0 ];
36
+
37
+ $ this ->assertEquals ($ expectedQuery , $ stmt ->build ());
38
+ }
39
+
40
+ public function testBuilderWithCommentsOnOptions (): void
41
+ {
42
+ $ query = 'ALTER EVENT `myEvent` /* comment */ ' .
43
+ 'ON SCHEDULE -- Comment at the end of the line ' . "\n" .
44
+ 'AT "2023-01-01 01:23:45" ' ;
45
+
46
+ $ expectedQuery = 'ALTER EVENT `myEvent` ' .
47
+ 'ON SCHEDULE AT "2023-01-01 01:23:45" ' ;
48
+
49
+ $ parser = new Parser ($ query );
50
+ $ stmt = $ parser ->statements [0 ];
51
+
52
+ $ this ->assertEquals ($ expectedQuery , $ stmt ->build ());
53
+ }
54
+
24
55
public function testBuilderCompressed (): void
25
56
{
26
57
$ query = 'ALTER TABLE `user` CHANGE `message` `message` TEXT COMPRESSED ' ;
@@ -34,7 +65,7 @@ public function testBuilderPartitions(): void
34
65
$ parser = new Parser ('ALTER TABLE t1 PARTITION BY HASH(id) PARTITIONS 8 ' );
35
66
$ stmt = $ parser ->statements [0 ];
36
67
37
- $ this ->assertEquals ('ALTER TABLE t1 PARTITION BY HASH(id) PARTITIONS 8 ' , $ stmt ->build ());
68
+ $ this ->assertEquals ('ALTER TABLE t1 PARTITION BY HASH(id) PARTITIONS 8 ' , $ stmt ->build ());
38
69
39
70
$ parser = new Parser ('ALTER TABLE t1 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2002)) ' );
40
71
$ stmt = $ parser ->statements [0 ];
@@ -50,16 +81,24 @@ public function testBuilderPartitions(): void
50
81
$ stmt = $ parser ->statements [0 ];
51
82
52
83
$ this ->assertEquals (
53
- 'ALTER TABLE p PARTITION BY LINEAR KEY ALGORITHM=2 (id) PARTITIONS 32 ' ,
84
+ 'ALTER TABLE p PARTITION BY LINEAR KEY ALGORITHM=2 (id) PARTITIONS 32 ' ,
54
85
$ stmt ->build ()
55
86
);
56
87
57
88
$ parser = new Parser ('ALTER TABLE t1 DROP PARTITION p0, p1; ' );
58
89
$ stmt = $ parser ->statements [0 ];
59
90
60
91
$ this ->assertEquals (
61
- 'ALTER TABLE t1 DROP PARTITION p0, p1 ' ,
92
+ 'ALTER TABLE t1 DROP PARTITION p0, p1 ' ,
62
93
$ stmt ->build ()
63
94
);
64
95
}
96
+
97
+ public function testBuilderEventWithDefiner (): void
98
+ {
99
+ $ query = 'ALTER DEFINER=user EVENT myEvent ENABLE ' ;
100
+ $ parser = new Parser ($ query );
101
+ $ stmt = $ parser ->statements [0 ];
102
+ $ this ->assertEquals ($ query , $ stmt ->build ());
103
+ }
65
104
}
0 commit comments