Store UUID filter values as compact binaries#4608
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4608 +/- ##
==========================================
+ Coverage 57.43% 59.00% +1.57%
==========================================
Files 342 385 +43
Lines 39928 42642 +2714
Branches 11597 12204 +607
==========================================
+ Hits 22931 25160 +2229
- Misses 16960 17407 +447
- Partials 37 75 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| end | ||
| end | ||
|
|
||
| def uuid_to_string(<<_::128>> = uuid), do: Ecto.UUID.load!(uuid) |
There was a problem hiding this comment.
How is this different from Casting.uuid_to_string(value)?
There was a problem hiding this comment.
It is not meaningfully different here: Ecto.UUID.cast/1 accepts both canonical UUID strings and raw 16-byte UUID binaries.
I removed the <<_::128>>/Ecto.UUID.load!/1 special case so uuid_to_string/1 uses the single Ecto.UUID.cast/1 path for both forms.
Verified with:
mix test test/electric/replication/eval/env_test.exs test/electric/replication/eval/sql_generator_test.exs test/electric/replication/eval/runner_test.exs test/electric/shapes/filter_test.exs| ) | ||
| |> Filter.add_shape( | ||
| "s2", | ||
| Shape.new!("uuid_table", where: "id = '#{uuid2}'::uuid", inspector: inspector) |
There was a problem hiding this comment.
what happens if we don't cast the value to uuid? If I were writing that where filter I wouldn't cast to uuid...
There was a problem hiding this comment.
Good point. The uncast form works: the unknown string literal is inferred from the UUID column side of the equality, and the equality index still stores the 16-byte UUID key.
I updated this test to use id = '...' rather than id = '...'::uuid, and verified it with:
mix test test/electric/shapes/filter_test.exs
Claude Code ReviewSummaryIteration 4 review. This PR stores parsed UUIDs as compact 16-byte binaries inside the sync-service eval/filter representation, converting back to canonical text at SQL and output boundaries. Since iteration 3 the author landed commit Previous Review Status
What's Working Well
Issues FoundCritical (Must Fix)None. Important (Should Fix)None remaining. Suggestions (Nice to Have)
Issue ConformanceNo linked issue (per review context); per project convention PRs should reference the issue they address — minor process note. The PR description is accurate and matches the implemented scope (representation change, boundary conversions, metadata bump, changeset for Overall: this iteration resolves the only remaining flagged issue. The PR looks ready to merge from a correctness standpoint; the two suggestions are optional cleanups. Review iteration: 4 | 2026-06-17 |
|
This PR has been released! 🚀 The following packages include changes from this PR:
Thanks for contributing to Electric! |
Summary
@core/sync-service.Testing
mix test test/electric/shape_cache/shape_status_test.exs test/electric/shape_cache/shape_status/shape_db_test.exsmix test --only oracle test/integration/oracle_property_test.exssuccessfully. This patch was not committed.CHECK_TIMEOUT=60000 SHAPE_COUNT=800 MUTATIONS_PER_TXN=10 TXNS_PER_BATCH=10 BATCH_COUNT=200 SKIP_REPATCH_PREWARM=true mix test --seed 8 --only oracle test/integration/oracle_property_test.exs. This patch was not committed.id = $1::uuidandid = CAST($1 AS uuid)against theitems.idUUID column; the four targeted tests passed and were not committed.