@@ -354,6 +354,7 @@ protected function formatChangeStreamOptions(ChangeStreamDefinition $definition)
354354 protected function addInterleaveToTable (Blueprint $ blueprint )
355355 {
356356 if (! is_null ($ command = $ this ->getCommandByName ($ blueprint , 'interleaveInParent ' ))) {
357+ assert ($ command instanceof InterleaveDefinition);
357358 $ schema = ", interleave in parent {$ this ->wrap ($ command ->table )}" ;
358359 if (! is_null ($ command ->onDelete )) {
359360 $ schema .= " on delete {$ command ->onDelete }" ;
@@ -403,27 +404,21 @@ public function compileUnique(Blueprint $blueprint, Fluent $command)
403404 */
404405 public function compileIndex (Blueprint $ blueprint , Fluent $ command )
405406 {
406- $ columnsAsString = null ;
407-
408407 // if index is defined as assoc array, key is treated as column name and value as order
409408 // if index is defined as numeric array, then values are read as column names
410- $ keys = array_keys ($ command ->columns );
411- if (array_keys ($ keys ) !== $ keys ) {
412- $ columns = [];
413- foreach ($ command ->columns as $ column => $ order ) {
414- $ columns [] = $ this ->wrap ($ column ).' ' .$ order ;
415- }
416- $ columnsAsString = implode (', ' , $ columns );
417- } else {
418- $ columnsAsString = $ this ->columnize ($ command ->columns );
409+ $ columns = [];
410+ foreach ($ command ->columns as $ column => $ order ) {
411+ $ columns [] = is_string ($ column )
412+ ? $ this ->wrap ($ column ) . ' ' . $ order
413+ : $ this ->wrap ($ order );
419414 }
420415
421416 return sprintf ('create %s%sindex %s on %s (%s)%s%s ' ,
422417 empty ($ command ->indexType ) ? '' : trim ($ command ->indexType ).' ' ,
423418 empty ($ command ->nullFiltered ) ? '' :'null_filtered ' ,
424419 $ this ->wrap ($ command ->index ),
425420 $ this ->wrapTable ($ blueprint ),
426- $ columnsAsString ,
421+ implode ( ' , ' , $ columns ) ,
427422 $ this ->addStoringToIndex ($ command ),
428423 $ this ->addInterleaveToIndex ($ command )
429424 );
@@ -458,7 +453,7 @@ protected function addStoringToIndex(Fluent $indexCommand): string
458453
459454 /**
460455 * @param Blueprint $blueprint
461- * @param Fluent<string, mixed> $command
456+ * @param IndexDefinition $command
462457 * @return string
463458 * @see https://cloud.google.com/spanner/docs/data-definition-language?hl=en
464459 */
@@ -471,7 +466,7 @@ public function compileDropIndex(Blueprint $blueprint, Fluent $command)
471466
472467 /**
473468 * @param Blueprint $blueprint
474- * @param Fluent<string, mixed> $command
469+ * @param IndexDefinition $command
475470 * @return string
476471 * @see https://cloud.google.com/spanner/docs/data-definition-language?hl=en
477472 */
@@ -484,7 +479,7 @@ public function compileDropUnique(Blueprint $blueprint, Fluent $command)
484479 * Compile a drop foreign key command.
485480 *
486481 * @param Blueprint $blueprint
487- * @param Fluent<string, mixed> $command
482+ * @param IndexDefinition $command
488483 * @return string
489484 */
490485 public function compileDropForeign (Blueprint $ blueprint , Fluent $ command )
0 commit comments