Skip to content

Commit

Permalink
feat(checks) manage multi in checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Narcisi authored and bouttier committed Feb 21, 2024
1 parent c5172cc commit 1c0a815
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions backend/geonature/core/imports/checks/sql/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ def init_rows_validity(imprt):
# TODO handle multi columns
# Currently if only a multi-fields is mapped, it will be ignored without raising any error.
# This is not a very big issue as it is unlikely to map **only** a multi-field.
selected_fields_names = [
field_name
for field_name, source_field in imprt.fieldmapping.items()
if source_field in imprt.columns
]
selected_fields_names = []
for field_name, source_field in imprt.fieldmapping.items():
if type(source_field) == list:
selected_fields_names.extend(set(source_field) & set(imprt.columns))
elif source_field in imprt.columns:
selected_fields_names.append(field_name)

for entity in entities:
# Select fields associated to this entity *and only to this entity*
fields = (
Expand All @@ -64,11 +66,13 @@ def check_orphan_rows(imprt):
transient_table = imprt.destination.get_transient_table()
# TODO: handle multi-source fields
# This is actually not a big issue as multi-source fields are unlikely to also be multi-entity fields.
selected_fields_names = [
field_name
for field_name, source_field in imprt.fieldmapping.items()
if source_field in imprt.columns
]
selected_fields_names = []
for field_name, source_field in imprt.fieldmapping.items():
if type(source_field) == list:
selected_fields_names.extend(set(source_field) & set(imprt.columns))
elif source_field in imprt.columns:
selected_fields_names.append(field_name)

# Select fields associated to multiple entities
AllEntityField = sa.orm.aliased(EntityField)
multientity_fields = (
Expand Down

0 comments on commit 1c0a815

Please sign in to comment.