Repository navigation
fix(mysql): handle X-prefix in binary transforms; add binary-to-uuid and binary-to-bytea (#1758) - #1761
Merged
Conversation
…and binary-to-bytea (#1758) MySQL BINARY/VARBINARY columns arrive in the v4 pipeline as "X{hex}" (capital X, no backslash). Several transforms checked only for the "\\x" (bytea-style) prefix and silently left the X in place. - byte-vector-to-hexstring: also strip bare "X" prefix so uuid columns work - binary-to-uuid: new transform for BINARY(16) → uuid with canonical hyphen layout - binary-to-bytea: new transform for BINARY/VARBINARY → bytea "\\x{hex}" format - hex-to-bytea: also strip bare "X" prefix for robustness - v3 parity: add binary-to-uuid and binary-to-bytea to transforms.lisp - tests: unit tests for all four functions; e2e mytest binary_types table
… expected files binary_types sorts before bit_defaults (binary < bit_d). 17-binary-types.out header needs trailing spaces to match psql output width.
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.
Problem
MySQL
BINARY/VARBINARYcolumn values arrive in the v4 pipeline as"X{lowercase hex}"(capital X, no backslash) — produced byconvert-mysql-value. Several transform functions were written expecting"\\x{hex}"(backslash-x, PostgreSQL bytea format) and silently mis-handle theXprefix.Changes
Fix 1 —
byte-vector-to-hexstring(clojure/src/pgloader/cast.clj)Previously only stripped the
\\xprefix; now also strips a bare capital-Xprefix so uuid columns receive plain lowercase hex without a leadingx.Fix 2 — New
binary-to-uuidtransformConverts a MySQL
BINARY(16)column (arriving as"X{32 hex chars}") to the canonical hyphenated PostgreSQL uuid formxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.Fix 3 — New
binary-to-byteatransformConverts a MySQL
BINARY/VARBINARYcolumn (arriving as"X{hex}") to the PostgreSQL bytea hex literal"\\x{hex}".Fix 4 —
hex-to-bytea(clojure/src/pgloader/cast.clj)Added bare
Xprefix handling to match the other transforms.Fix 5 — v3 parity (
src/utils/transforms.lisp)Added
binary-to-uuidandbinary-to-byteato the CL transforms. v3 receives actual byte vectors (not X-hex strings), so the implementations differ from v4 but produce identical output.Tests
deftestforms inclojure/test/pgloader/cast_test.cljcovering all four fixed/new functions (22 tests, 83 assertions — all pass)binary_typestable added to the mytest MySQL seed; cast rules added tomytest.load; query 17 verifies the uuid and bytea round-tripCloses #1758