7
7
use Vimeo \MysqlEngine \FakePdoInterface ;
8
8
use Vimeo \MysqlEngine \Query \ShowIndexQuery ;
9
9
use Vimeo \MysqlEngine \Schema \Column ;
10
+ use function PHPUnit \Framework \assertIsArray ;
10
11
11
12
class ShowIndexProcessor extends Processor
12
13
{
@@ -20,15 +21,18 @@ public static function process(
20
21
$ database ,
21
22
$ table
22
23
);
24
+ if (!$ table_definition ) {
25
+ return new QueryResult ([], []);
26
+ }
23
27
$ columns = [
24
28
'Table ' => new Column \Varchar (255 ),
25
29
'Non_unique ' => new Column \TinyInt (true , 1 ),
26
30
'Key_name ' => new Column \Varchar (255 ),
27
- 'Seq_in_index ' => new Column \intColumn (true , 4 ),
31
+ 'Seq_in_index ' => new Column \IntColumn (true , 4 ),
28
32
'Column_name ' => new Column \Varchar (255 ),
29
33
'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 ),
32
36
'Packed ' => new Column \TinyInt (true , 1 ),
33
37
'Null ' => new Column \Varchar (3 ),
34
38
'Index_type ' => new Column \Varchar (5 ),
@@ -42,7 +46,7 @@ public static function process(
42
46
'Table ' => $ table_definition ->name ,
43
47
'Non_unique ' => $ index ->type === 'INDEX ' ? 1 : 0 ,
44
48
'Key_name ' => $ name ,
45
- 'Seq_in_index ' => $ i + 1 ,
49
+ 'Seq_in_index ' => 1 + ( int ) $ i ,
46
50
'Column_name ' => $ column ,
47
51
// because Index does not have "direction" (in the $cols of CreateIndex)
48
52
'Collation ' => null ,
0 commit comments