@@ -142,6 +142,60 @@ public function testParseKeyWithLengthWithOptions(): void
142142 );
143143 }
144144
145+ public function testParseKeyWithLengthWithAllOptions (): void
146+ {
147+ $ component = Key::parse (
148+ new Parser (),
149+ $ this ->getTokensList (
150+ // This is not a vary plausible example but it runs
151+ // Only ENGINE_ATTRIBUTE gives a not supported error but is still a valid syntax
152+ 'KEY `alias_type_idx` (`alias_type`(10)) '
153+ . ' COMMENT \'my comment \' VISIBLE KEY_BLOCK_SIZE=1 '
154+ . ' INVISIBLE ENGINE_ATTRIBUTE \'foo \' SECONDARY_ENGINE_ATTRIBUTE= \'bar \' USING BTREE, '
155+ )
156+ );
157+ $ this ->assertEquals ('KEY ' , $ component ->type );
158+ $ this ->assertEquals ('alias_type_idx ' , $ component ->name );
159+ $ this ->assertEquals (new OptionsArray (
160+ [
161+ 1 => [
162+ 'name ' => 'KEY_BLOCK_SIZE ' ,
163+ 'equals ' => true ,
164+ 'expr ' => '1 ' ,
165+ 'value ' => '1 ' ,
166+ ],
167+ 2 => [
168+ 'name ' => 'USING ' ,
169+ 'equals ' => false ,
170+ 'expr ' => 'BTREE ' ,
171+ 'value ' => 'BTREE ' ,
172+ ],
173+ 4 => [
174+ 'name ' => 'COMMENT ' ,
175+ 'equals ' => false ,
176+ 'expr ' => '\'my comment \'' ,
177+ 'value ' => 'my comment ' ,
178+ ],
179+ 5 => [
180+ 'name ' => 'ENGINE_ATTRIBUTE ' ,
181+ 'equals ' => true ,
182+ 'expr ' => '\'foo \'' ,
183+ 'value ' => 'foo ' ,
184+ ],
185+ 6 => 'VISIBLE ' ,
186+ 12 => 'INVISIBLE ' ,
187+ 13 => [
188+ 'name ' => 'SECONDARY_ENGINE_ATTRIBUTE ' ,
189+ 'equals ' => true ,
190+ 'expr ' => '\'bar \'' ,
191+ 'value ' => 'bar ' ,
192+ ],
193+ ]
194+ ), $ component ->options );
195+ $ this ->assertNull ($ component ->expr );
196+ $ this ->assertSame ([['name ' => 'alias_type ' , 'length ' => 10 ]], $ component ->columns );
197+ }
198+
145199 public function testParseKeyExpressionWithoutOptions (): void
146200 {
147201 $ component = Key::parse (
0 commit comments