File tree Expand file tree Collapse file tree 2 files changed +42
-18
lines changed Expand file tree Collapse file tree 2 files changed +42
-18
lines changed Original file line number Diff line number Diff line change @@ -136,13 +136,21 @@ public function create(): Index
136136 throw InvalidIndexDefinition::columnsNotSet ($ this ->name );
137137 }
138138
139- $ columnNames = $ lengths = $ flags = [];
140- foreach ($ this ->columns as $ column ) {
139+ $ columnNames = $ lengths = $ options = $ flags = [];
140+ foreach ($ this ->columns as $ i => $ column ) {
141141 $ columnNames [] = $ column ->getColumnName ()->toString ();
142- $ lengths [] = $ column ->getLength ();
142+
143+ $ length = $ column ->getLength ();
144+ if ($ length === null ) {
145+ continue ;
146+ }
147+
148+ $ lengths [$ i ] = $ column ->getLength ();
143149 }
144150
145- $ options = ['lengths ' => $ lengths ];
151+ if (count ($ lengths ) !== 0 ) {
152+ $ options ['lengths ' ] = $ lengths ;
153+ }
146154
147155 if ($ this ->type === IndexType::FULLTEXT ) {
148156 $ flags [] = 'fulltext ' ;
Original file line number Diff line number Diff line change @@ -473,21 +473,37 @@ public function testCompareColumnCompareCaseInsensitive(): void
473473
474474 public function testCompareIndexBasedOnPropertiesNotName (): void
475475 {
476- $ tableA = new Table ('foo ' , [
477- Column::editor ()
478- ->setUnquotedName ('id ' )
479- ->setTypeName (Types::INTEGER )
480- ->create (),
481- ]);
482- $ tableA ->addIndex (['id ' ], 'foo_bar_idx ' );
476+ $ tableA = Table::editor ()
477+ ->setUnquotedName ('foo ' )
478+ ->setColumns (
479+ Column::editor ()
480+ ->setUnquotedName ('id ' )
481+ ->setTypeName (Types::INTEGER )
482+ ->create (),
483+ )
484+ ->setIndexes (
485+ Index::editor ()
486+ ->setUnquotedName ('foo_bar_idx ' )
487+ ->setUnquotedColumnNames ('id ' )
488+ ->create (),
489+ )
490+ ->create ();
483491
484- $ tableB = new Table ('foo ' , [
485- Column::editor ()
486- ->setUnquotedName ('ID ' )
487- ->setTypeName (Types::INTEGER )
488- ->create (),
489- ]);
490- $ tableB ->addIndex (['id ' ], 'bar_foo_idx ' );
492+ $ tableB = Table::editor ()
493+ ->setUnquotedName ('foo ' )
494+ ->setColumns (
495+ Column::editor ()
496+ ->setUnquotedName ('ID ' )
497+ ->setTypeName (Types::INTEGER )
498+ ->create (),
499+ )
500+ ->setIndexes (
501+ Index::editor ()
502+ ->setUnquotedName ('bar_foo_idx ' )
503+ ->setUnquotedColumnNames ('id ' )
504+ ->create (),
505+ )
506+ ->create ();
491507
492508 self ::assertEquals (
493509 new TableDiff ($ tableA , renamedIndexes: [
You can’t perform that action at this time.
0 commit comments