77use Vimeo \MysqlEngine \FakePdoInterface ;
88use Vimeo \MysqlEngine \Query \ShowIndexQuery ;
99use Vimeo \MysqlEngine \Schema \Column ;
10+ use function PHPUnit \Framework \assertIsArray ;
1011
1112class ShowIndexProcessor extends Processor
1213{
@@ -20,15 +21,18 @@ public static function process(
2021 $ database ,
2122 $ table
2223 );
24+ if (!$ table_definition ) {
25+ return new QueryResult ([], []);
26+ }
2327 $ columns = [
2428 'Table ' => new Column \Varchar (255 ),
2529 'Non_unique ' => new Column \TinyInt (true , 1 ),
2630 'Key_name ' => new Column \Varchar (255 ),
27- 'Seq_in_index ' => new Column \intColumn (true , 4 ),
31+ 'Seq_in_index ' => new Column \IntColumn (true , 4 ),
2832 'Column_name ' => new Column \Varchar (255 ),
2933 'Collation ' => new Column \Char (1 ),
30- 'Cardinality ' => new Column \intColumn (true , 4 ),
31- 'Sub_part ' => new Column \intColumn (true , 4 ),
34+ 'Cardinality ' => new Column \IntColumn (true , 4 ),
35+ 'Sub_part ' => new Column \IntColumn (true , 4 ),
3236 'Packed ' => new Column \TinyInt (true , 1 ),
3337 'Null ' => new Column \Varchar (3 ),
3438 'Index_type ' => new Column \Varchar (5 ),
@@ -42,7 +46,7 @@ public static function process(
4246 'Table ' => $ table_definition ->name ,
4347 'Non_unique ' => $ index ->type === 'INDEX ' ? 1 : 0 ,
4448 'Key_name ' => $ name ,
45- 'Seq_in_index ' => $ i + 1 ,
49+ 'Seq_in_index ' => 1 + ( int ) $ i ,
4650 'Column_name ' => $ column ,
4751 // because Index does not have "direction" (in the $cols of CreateIndex)
4852 'Collation ' => null ,
0 commit comments