Skip to content

Commit

Permalink
[DH-5513] For table-descriptions Don't update columns when they send …
Browse files Browse the repository at this point in the history
…an empty list (#414)
  • Loading branch information
jcjc712 authored Feb 28, 2024
1 parent ea3e009 commit 2e8b4f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dataherald/db_scanner/repository/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def get_all_tables_by_db(self, query: dict) -> List[TableDescription]:
def save_table_info(self, table_info: TableDescription) -> TableDescription:
table_info_dict = table_info.dict(exclude={"id"})
table_info_dict["db_connection_id"] = str(table_info.db_connection_id)
table_info_dict = {k: v for k, v in table_info_dict.items() if v is not None}
table_info_dict = {
k: v for k, v in table_info_dict.items() if v is not None and v != []
}
table_info.id = str(
self.storage.update_or_create(
DB_COLLECTION,
Expand All @@ -65,7 +67,9 @@ def save_table_info(self, table_info: TableDescription) -> TableDescription:
def update(self, table_info: TableDescription) -> TableDescription:
table_info_dict = table_info.dict(exclude={"id"})
table_info_dict["db_connection_id"] = str(table_info.db_connection_id)
table_info_dict = {k: v for k, v in table_info_dict.items() if v is not None}
table_info_dict = {
k: v for k, v in table_info_dict.items() if v is not None and v != []
}
self.storage.update_or_create(
DB_COLLECTION,
{"_id": ObjectId(table_info.id)},
Expand Down Expand Up @@ -113,7 +117,7 @@ def update_fields(self, table: TableDescription, table_description_request):
for column in table.columns:
if column_request.name == column.name:
for field, value in column_request:
if value is None:
if value is None or value == []:
continue
setattr(column, field, value)
return self.update(table)

0 comments on commit 2e8b4f3

Please sign in to comment.