mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 01:15:08 +00:00
Fix Duplicate table constraints (#19502)
This commit is contained in:
parent
1e7377c2e4
commit
94ed7e3c1a
@ -683,7 +683,7 @@ class CommonDbSourceService(
|
||||
foreign_constraint = self._prepare_foreign_constraints(
|
||||
supports_database, column, table_name, schema_name, db_name, columns
|
||||
)
|
||||
if foreign_constraint:
|
||||
if foreign_constraint and foreign_constraint not in foreign_constraints:
|
||||
foreign_constraints.append(foreign_constraint)
|
||||
|
||||
return foreign_constraints
|
||||
@ -707,7 +707,11 @@ class CommonDbSourceService(
|
||||
)
|
||||
if foreign_table_constraints:
|
||||
if table_constraints:
|
||||
table_constraints.extend(foreign_table_constraints)
|
||||
table_constraints.extend(
|
||||
constraint
|
||||
for constraint in foreign_table_constraints
|
||||
if constraint not in table_constraints
|
||||
)
|
||||
else:
|
||||
table_constraints = foreign_table_constraints
|
||||
return table_constraints
|
||||
|
@ -226,12 +226,16 @@ class SqlColumnHandlerMixin:
|
||||
if len(col) == 1:
|
||||
column_level_unique_constraints.add(col[0])
|
||||
else:
|
||||
table_constraints.append(
|
||||
TableConstraint(
|
||||
constraintType=ConstraintType.UNIQUE,
|
||||
columns=col,
|
||||
if not any(
|
||||
tc.constraintType == ConstraintType.UNIQUE and tc.columns == col
|
||||
for tc in table_constraints
|
||||
):
|
||||
table_constraints.append(
|
||||
TableConstraint(
|
||||
constraintType=ConstraintType.UNIQUE,
|
||||
columns=col,
|
||||
)
|
||||
)
|
||||
)
|
||||
if len(pk_columns) > 1:
|
||||
table_constraints.append(
|
||||
TableConstraint(
|
||||
|
Loading…
x
Reference in New Issue
Block a user