44
55namespace Yiisoft \Db \Mssql ;
66
7- use Yiisoft \Db \Constraint \CheckConstraint ;
8- use Yiisoft \Db \Constraint \DefaultValueConstraint ;
9- use Yiisoft \Db \Constraint \ForeignKeyConstraint ;
10- use Yiisoft \Db \Constraint \IndexConstraint ;
7+ use Yiisoft \Db \Constraint \Check ;
8+ use Yiisoft \Db \Constraint \DefaultValue ;
9+ use Yiisoft \Db \Constraint \ForeignKey ;
10+ use Yiisoft \Db \Constraint \Index ;
1111use Yiisoft \Db \Driver \Pdo \AbstractPdoSchema ;
1212use Yiisoft \Db \Exception \Exception ;
1313use Yiisoft \Db \Helper \DbArrayHelper ;
@@ -197,15 +197,15 @@ protected function loadTableSchema(string $name): TableSchemaInterface|null
197197 return null ;
198198 }
199199
200- protected function loadTablePrimaryKey (string $ tableName ): IndexConstraint |null
200+ protected function loadTablePrimaryKey (string $ tableName ): Index |null
201201 {
202- /** @var IndexConstraint |null */
202+ /** @var Index |null */
203203 return $ this ->loadTableConstraints ($ tableName , self ::PRIMARY_KEY );
204204 }
205205
206206 protected function loadTableForeignKeys (string $ tableName ): array
207207 {
208- /** @var ForeignKeyConstraint [] */
208+ /** @var ForeignKey [] */
209209 return $ this ->loadTableConstraints ($ tableName , self ::FOREIGN_KEYS );
210210 }
211211
@@ -241,7 +241,7 @@ protected function loadTableIndexes(string $tableName): array
241241 * > $indexes
242242 */
243243 foreach ($ indexes as $ name => $ index ) {
244- $ result [] = new IndexConstraint (
244+ $ result [] = new Index (
245245 $ name ,
246246 array_column ($ index , 'column_name ' ),
247247 (bool ) $ index [0 ]['is_unique ' ],
@@ -254,19 +254,19 @@ protected function loadTableIndexes(string $tableName): array
254254
255255 protected function loadTableUniques (string $ tableName ): array
256256 {
257- /** @var IndexConstraint [] */
257+ /** @var Index [] */
258258 return $ this ->loadTableConstraints ($ tableName , self ::UNIQUES );
259259 }
260260
261261 protected function loadTableChecks (string $ tableName ): array
262262 {
263- /** @var CheckConstraint [] */
263+ /** @var Check [] */
264264 return $ this ->loadTableConstraints ($ tableName , self ::CHECKS );
265265 }
266266
267267 protected function loadTableDefaultValues (string $ tableName ): array
268268 {
269- /** @var DefaultValueConstraint [] */
269+ /** @var DefaultValue [] */
270270 return $ this ->loadTableConstraints ($ tableName , self ::DEFAULTS );
271271 }
272272
@@ -537,10 +537,10 @@ public function findUniqueIndexes(TableSchemaInterface $table): array
537537 * - checks
538538 * - defaults
539539 *
540- * @return CheckConstraint []|DefaultValueConstraint []|ForeignKeyConstraint []|IndexConstraint|IndexConstraint []|null
540+ * @return Check []|DefaultValue []|ForeignKey []|Index|Index []|null
541541 * Constraints of the specified type.
542542 */
543- private function loadTableConstraints (string $ tableName , string $ returnType ): array |IndexConstraint |null
543+ private function loadTableConstraints (string $ tableName , string $ returnType ): array |Index |null
544544 {
545545 $ sql = <<<SQL
546546 SELECT
@@ -604,31 +604,32 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
604604 foreach ($ names as $ name => $ constraint ) {
605605 /** @psalm-suppress ArgumentTypeCoercion */
606606 match ($ type ) {
607- 'PK ' => $ result [self ::PRIMARY_KEY ] = new IndexConstraint (
607+ 'PK ' => $ result [self ::PRIMARY_KEY ] = new Index (
608608 $ name ,
609609 array_column ($ constraint , 'column_name ' ),
610610 true ,
611611 true ,
612612 ),
613- 'F ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKeyConstraint (
613+ 'F ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKey (
614614 $ name ,
615615 array_column ($ constraint , 'column_name ' ),
616- $ constraint [0 ]['foreign_table_schema ' ] . '. ' . $ constraint [0 ]['foreign_table_name ' ],
616+ $ constraint [0 ]['foreign_table_schema ' ],
617+ $ constraint [0 ]['foreign_table_name ' ],
617618 array_column ($ constraint , 'foreign_column_name ' ),
618- str_replace ('_ ' , ' ' , $ constraint [0 ]['on_update ' ]),
619619 str_replace ('_ ' , ' ' , $ constraint [0 ]['on_delete ' ]),
620+ str_replace ('_ ' , ' ' , $ constraint [0 ]['on_update ' ]),
620621 ),
621- 'UQ ' => $ result [self ::UNIQUES ][] = new IndexConstraint (
622+ 'UQ ' => $ result [self ::UNIQUES ][] = new Index (
622623 $ name ,
623624 array_column ($ constraint , 'column_name ' ),
624625 true ,
625626 ),
626- 'C ' => $ result [self ::CHECKS ][] = new CheckConstraint (
627+ 'C ' => $ result [self ::CHECKS ][] = new Check (
627628 $ name ,
628629 array_column ($ constraint , 'column_name ' ),
629630 $ constraint [0 ]['check_expr ' ],
630631 ),
631- 'D ' => $ result [self ::DEFAULTS ][] = new DefaultValueConstraint (
632+ 'D ' => $ result [self ::DEFAULTS ][] = new DefaultValue (
632633 $ name ,
633634 array_column ($ constraint , 'column_name ' ),
634635 $ constraint [0 ]['default_expr ' ],
0 commit comments