-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply: Support merge function for CockroachDB target
This change is part of #487 to support three-way merges. This change updates the apply package to call into the merge function when targeting CockroachDB or PostgreSQL. The conditional-upsert SQL is extended to return the index of the conflicting data and the contents of the blocking row. The blocking and conflicting row data are then used to drive the merge function. The merge API added in PR #534 is refined. The relevent types are extracted into their own package, which contains a new "Bag" type. A Bag holds reified properties and can represent the data in a mutation or in a database row. It additonally classifies properties as being "mapped" or "unmapped" as to whether or not the property maps onto a known column. Some of the bookkeeping previously in the apply code to track missing or extra properties is simplified. The upsert code also becomes recursive. Mutations are reified into Bags and are applied. If a Bag generates a conflict, the merge function will be called to produce a Bag that will be unconditionally applied. Once all conflicts have been resolved, the accumulated Bags will be upserted by a recursive call to the upsert method. There is only ever one level of recursion.
- Loading branch information
Showing
19 changed files
with
921 additions
and
223 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
Oops, something went wrong.