mirror of
https://github.com/langgenius/dify.git
synced 2026-05-01 07:58:02 +08:00
fix: correctly detect required columns in archived workflow run restore (#33403)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -358,21 +358,19 @@ class WorkflowRunRestore:
|
||||
self,
|
||||
model: type[DeclarativeBase] | Any,
|
||||
) -> tuple[set[str], set[str], set[str]]:
|
||||
columns = list(model.__table__.columns)
|
||||
table = model.__table__
|
||||
columns = list(table.columns)
|
||||
autoincrement_column = getattr(table, "autoincrement_column", None)
|
||||
|
||||
def has_insert_default(column: Any) -> bool:
|
||||
# SQLAlchemy may set column.autoincrement to "auto" on non-PK columns.
|
||||
# Only treat the resolved autoincrement column as DB-generated.
|
||||
return column.default is not None or column.server_default is not None or column is autoincrement_column
|
||||
|
||||
column_names = {column.key for column in columns}
|
||||
required_columns = {
|
||||
column.key
|
||||
for column in columns
|
||||
if not column.nullable
|
||||
and column.default is None
|
||||
and column.server_default is None
|
||||
and not column.autoincrement
|
||||
}
|
||||
required_columns = {column.key for column in columns if not column.nullable and not has_insert_default(column)}
|
||||
non_nullable_with_default = {
|
||||
column.key
|
||||
for column in columns
|
||||
if not column.nullable
|
||||
and (column.default is not None or column.server_default is not None or column.autoincrement)
|
||||
column.key for column in columns if not column.nullable and has_insert_default(column)
|
||||
}
|
||||
return column_names, required_columns, non_nullable_with_default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user