Skip to content

fix(mapping): preserve excluded_attributes on update, backfill relationship source/target class - #178

Open
benoitcayladbx wants to merge 1 commit into
0.9.0from
fix/mapping-backend-excluded-attributes-and-class-resolution
Open

benoitcayladbx wants to merge 1 commit into
0.9.0from
fix/mapping-backend-excluded-attributes-and-class-resolution

Conversation

@benoitcayladbx

Copy link
Copy Markdown
Collaborator

Reopened against 0.9.0 after develop was deleted. GitHub cannot reopen #152 (closed PR + missing base), so this is a successor of #152 with the same commits. Original author: @jeremiaspf. Please rebase onto current 0.9.0 before review — expect conflicts.


What

Companion backend fix to #150 (the Manual Mapping save-state PR), in src/back/objects/mapping/Mapping.py:

  • When updating an existing entity or relationship mapping, if the incoming payload omits excluded_attributes but the previous mapping had one, that list is now carried forward. Previously only the general excluded flag was preserved this way, not the concrete excluded_attributes list — so re-saving a mapping that had excluded attributes could silently re-include them.
  • When resolving a relationship's source_class/target_class for consistency checks, if those fields are empty — as they always are for relationships saved via Manual Mapping, which never sends them — they're now backfilled from the corresponding ontology property's rdfs:domain/rdfs:range instead of being left empty.

Why

#150 stops new Manual Mapping saves from losing source_class/target_class/excluded_attributes going forward. This PR is the counterpart for mappings that already exist without them (created before #150, or from any other code path that doesn't send those fields) — the consistency check now recovers what it needs from the ontology itself rather than reporting incomplete data for an otherwise-correctly-configured relationship.

A note on how this PR came together

This is a delayed follow-up to #146#150: when we first put those together, Mapping.py had since grown a substantial schema-drift feature on develop that we hadn't checked our change against, so we held it back. We've now verified this patch applies cleanly on top of that feature with no overlap at all — the drift-detection code and this fix touch entirely different methods — so there was nothing to reconcile, just due diligence to do first.

How to test

  1. Create an entity mapping with an excluded attribute, save, then re-save the mapping without explicitly re-sending excluded_attributes (e.g. via a code path that omits it) — the attribute should stay excluded instead of reappearing.
  2. Create a relationship via Manual Mapping (which never sends source_class/target_class), then run the mapping consistency check — source_class/target_class should resolve from the property's domain/range instead of showing empty.

…onship source/target class

When updating an existing entity or relationship mapping, if the incoming
payload omits excluded_attributes but the previous mapping had one, that
list is now carried forward — previously only the general excluded flag
was preserved, not the concrete list, so re-saving a mapping that had
excluded attributes could silently re-include them.

When resolving source_class/target_class for a relationship's consistency
checks, if those fields are empty — as they always are for relationships
saved via Manual Mapping, which never sends them — they're now backfilled
from the corresponding ontology property's rdfs:domain/rdfs:range instead
of being left empty. This is the backend counterpart to the companion
Manual Mapping PR, which stops the gap from being created going forward;
this fix handles mappings that already have it.

Verified this applies cleanly on top of develop's schema-drift feature
added to this file since 0.7.1 — the two are unrelated and don't overlap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants