Dedupe custom field definitions on re-import#75
Merged
Conversation
Restoring a Sheaf export into a system that already had its custom fields stacked a second copy of every definition, since the importer created them unconditionally. Dedupe by (name, type) against the target system and within the file itself, reusing the existing definition rather than minting a twin. Members aren't deduped, so their values still attach to the fresh member rows under the shared definition. Field-value inserts now guard (field_id, member_id) uniqueness in-run so a reused definition (a file with duplicate defs, or future deduped members) can't trip the UNIQUE constraint mid-import. Left as additive follow-up work: member deduplication.
The v0.2.2 bump updated pyproject but not uv.lock, so the lockfile's sheaf package version drifted. Only the version field changes; no dependency resolutions move.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restoring a Sheaf export into a system that already had its custom fields stacked a second copy of every definition ("Pronouns", "Pronouns", ...), because the importer created definitions unconditionally. This dedupes them. Follow-up to the import-completeness work merged in #74; sequenced as unreleased (not folded into v0.2.2).
Change
(name, type)against the target system and within the file itself, reusing the existing definition rather than minting a twin. The system's own config (privacy / order / options) on a reused field is left untouched.(field_id, member_id)uniqueness in-run, so a reused definition (a file with duplicate defs, or future deduped members) can't trip theUNIQUE(field_id, member_id)constraint mid-import.Also
uv.lockto0.2.2(the v0.2.2 bump updated pyproject but not the lockfile; only the version field moves, no dependency resolutions change). Same lockfile-drift class as thepackage-lock.jsonfix in v0.2.2.Tests
11 passedacross the import runner + preview suite; ruff clean.Not in scope
Member deduplication (re-import stays additive for members).