Skip to content

Commit 71e51d0

Browse files
authored
Fix table_description refresh (#415)
1 parent 2e8b4f3 commit 71e51d0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

dataherald/db_scanner/sqlalchemy.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,28 @@ def refresh_tables(
6464
metadata: dict = None,
6565
) -> list[TableDescription]:
6666
stored_tables = repository.find_by({"db_connection_id": str(db_connection_id)})
67+
stored_tables_list = [table.table_name for table in stored_tables]
6768

6869
rows = []
6970
for table_description in stored_tables:
7071
if table_description.table_name not in tables:
7172
table_description.status = TableDescriptionStatus.DEPRECATED.value
7273
rows.append(repository.save_table_info(table_description))
74+
else:
75+
rows.append(TableDescription(**table_description.dict()))
76+
7377
for table in tables:
74-
rows.append(
75-
repository.save_table_info(
76-
TableDescription(
77-
db_connection_id=db_connection_id,
78-
table_name=table,
79-
status=TableDescriptionStatus.NOT_SCANNED.value,
80-
metadata=metadata,
78+
if table not in stored_tables_list:
79+
rows.append(
80+
repository.save_table_info(
81+
TableDescription(
82+
db_connection_id=db_connection_id,
83+
table_name=table,
84+
status=TableDescriptionStatus.NOT_SCANNED.value,
85+
metadata=metadata,
86+
)
8187
)
8288
)
83-
)
8489
return rows
8590

8691
@override

0 commit comments

Comments
 (0)