Skip to content

Commit 5e76e53

Browse files
committed
Fix sync schema method
1 parent e3800f8 commit 5e76e53

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Diff for: dataherald/api/fastapi.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ def scan_db(
144144

145145
db_connection_repository = DatabaseConnectionRepository(self.storage)
146146
scanner = self.system.instance(Scanner)
147+
rows = scanner.synchronizing(
148+
scanner_request,
149+
TableDescriptionRepository(self.storage),
150+
)
147151
database_connection_service = DatabaseConnectionService(scanner, self.storage)
148152
for schema, table_descriptions in data.items():
149153
db_connection = db_connection_repository.find_by_id(
@@ -156,11 +160,7 @@ def scan_db(
156160
background_tasks.add_task(
157161
async_scanning, scanner, database, table_descriptions, self.storage
158162
)
159-
return [
160-
TableDescriptionResponse(**row.dict())
161-
for _, table_descriptions in data.items()
162-
for row in table_descriptions
163-
]
163+
return [TableDescriptionResponse(**row.dict()) for row in rows]
164164

165165
@override
166166
def create_database_connection(

Diff for: dataherald/db_scanner/sqlalchemy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ def synchronizing(
102102
scanner_request: ScannerRequest,
103103
repository: TableDescriptionRepository,
104104
) -> list[TableDescription]:
105-
# persist tables to be scanned
106105
rows = []
107-
for table in scanner_request.table_names:
106+
for id in scanner_request.ids:
107+
table_description = repository.find_by_id(id)
108108
rows.append(
109109
repository.save_table_info(
110110
TableDescription(
111-
db_connection_id=scanner_request.db_connection_id,
112-
table_name=table,
111+
db_connection_id=table_description.db_connection_id,
112+
table_name=table_description.table_name,
113113
status=TableDescriptionStatus.SYNCHRONIZING.value,
114114
metadata=scanner_request.metadata,
115115
)

0 commit comments

Comments
 (0)