Repository navigation
Remove the code duplication flagged by cargo-echoes - #89
Merged
Merged
Conversation
Maxwell and wal2json decoded integers, integers that overflow to text and floats with three identical bodies each. They now call decode_json_int, decode_json_int64_or_text and decode_json_real in json_decoders, beside the decoders the two sources already shared. ChangesetOp::of_stored and PatchsetOp::of_stored build the view of one stored operation, which the four iter methods of DiffSetBuilder and DiffSet spelled out, and add_insert holds the insert both formats perform.
The changeset and patchset Digestable impls of wal2json v1 and v2, Maxwell and pg_walstream repeated one match each and differed only in their UPDATE and DELETE builders. Each source now has one digest function that takes those two builders, and the impls pass theirs.
The four DELETE and UPDATE formatters each wrote the column = value loop with its separator and its unnamed-column fallback. push_cells writes it once, pk_cells and set_cells select the key cells and the changed cells.
parse_as walks the tables of either format with the format's operation parser, parse_row reads a full row image, and parse_insert handles the INSERT body both formats store alike.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
cargo-echoes found function bodies written once for changesets and again for patchsets, or once per wire source. Each pair now calls one shared helper, covering the binary parse loop, the JSON number decoders, the per-source digest bodies, the SQL WHERE and SET cell builders, the primary key WHERE parsing in the SQL parser, the update consolidation steps, the hex digit decoder and the column set loop in the wire builders.
The digestion tests share their row assertions through
tests/common, and the benches, compile-bench and payload-size-bench plots share their setup blocks. Two tests that were exact copies of other tests are gone.The diesel e2e scenarios now live once in the
diesel_e2elib, generic over the diesel connection with an async twin. Each backend file keeps its DDL and container boot. Every backend now runs the union of the assertions the per-backend copies used to make.