Skip to content

Commit

Permalink
Fix table_description refresh (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjc712 authored Feb 29, 2024
1 parent 2e8b4f3 commit 71e51d0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions dataherald/db_scanner/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,28 @@ def refresh_tables(
metadata: dict = None,
) -> list[TableDescription]:
stored_tables = repository.find_by({"db_connection_id": str(db_connection_id)})
stored_tables_list = [table.table_name for table in stored_tables]

rows = []
for table_description in stored_tables:
if table_description.table_name not in tables:
table_description.status = TableDescriptionStatus.DEPRECATED.value
rows.append(repository.save_table_info(table_description))
else:
rows.append(TableDescription(**table_description.dict()))

for table in tables:
rows.append(
repository.save_table_info(
TableDescription(
db_connection_id=db_connection_id,
table_name=table,
status=TableDescriptionStatus.NOT_SCANNED.value,
metadata=metadata,
if table not in stored_tables_list:
rows.append(
repository.save_table_info(
TableDescription(
db_connection_id=db_connection_id,
table_name=table,
status=TableDescriptionStatus.NOT_SCANNED.value,
metadata=metadata,
)
)
)
)
return rows

@override
Expand Down

0 comments on commit 71e51d0

Please sign in to comment.