-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(import): support fieldmapping format v2
- Loading branch information
Showing
8 changed files
with
106 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,16 +474,20 @@ def import_data_to_destination(imprt: TImports) -> None: | |
ef.field.name_field: ef.field for ef in entity.fields if ef.field.dest_field != None | ||
} | ||
insert_fields = {fields["id_station"]} | ||
for field_name, source_field in imprt.fieldmapping.items(): | ||
for field_name, mapping in imprt.fieldmapping.items(): | ||
if field_name not in fields: # not a destination field | ||
continue | ||
field = fields[field_name] | ||
column_src = mapping.get("column_src", None) | ||
if field.multi: | ||
# [email protected]_import_valid_file: add testcase | ||
if not set(source_field).isdisjoint(imprt.columns): | ||
if not set(column_src).isdisjoint(imprt.columns): | ||
insert_fields |= {field} | ||
else: | ||
if source_field in imprt.columns: | ||
if ( | ||
column_src in imprt.columns | ||
or mapping.get("default_value", None) is not None | ||
): | ||
insert_fields |= {field} | ||
if entity.code == "station": | ||
# unique_dataset_id is replaced with id_dataset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters