Expand description
Delta merge: combine same-named DB/Loc tables by row identity instead of blindly concatenating every row.
The plain DB::merge/Loc::merge
append every source row verbatim, so two mods editing the same rows produce duplicates instead of a
combined result. This module instead matches rows by their schema key column(s)
(Definition::key_column_positions), and for a key shared by more than one source resolves each
field individually:
- All contributing sources agree on the value: keep it.
- They disagree, but only one of them actually diverges from the vanilla/parent baseline: keep the one that diverges (that source is the only one that touched this field).
- Otherwise it’s a genuine conflict (including a row that’s brand new, with different data, in more
than one source, since there’s no baseline to break the tie): reported as a
MergeConflictunless the caller already supplied aMergeResolutionfor it.
Tables with no key column can’t be matched by row identity at all, so delta merge degrades to plain concatenation for them.
Structs§
- Merge
Candidate - One of the candidate values for a
MergeConflict. - Merge
Conflict - A single field that two or more sources changed in incompatible ways, needing a user decision.
- Merge
Options - Configuration for a table merge.
- Merge
Resolution - The user’s chosen value for one
MergeConflict, fed back into a follow-up merge attempt.
Functions§
- db_
baseline - Flattens the vanilla/parent versions of a DB table (in load order) into a single baseline table,
for use as the
baselineargument ofdelta_merge_db. ReturnsNoneif the table isn’t loaded. - delta_
merge_ db - Delta-merges multiple DB tables of the same name into one, using
baseline(the vanilla/parent version of the table, if any) to tell an intentional edit apart from an untouched row. - delta_
merge_ loc - Delta-merges multiple Loc tables into one. See
delta_merge_dbfor the general behavior; Loc tables always key on their singlekeycolumn. - loc_
baseline - Flattens the vanilla/parent Loc tables (in load order) into a single baseline table, for use as the
baselineargument ofdelta_merge_loc. ReturnsNoneif no Loc data is loaded.