Repository navigation
Conversation
SQLite BLOB values were turned into strings with (str byte[]), so PostgreSQL received "[B@<hash>" instead of the bytes. Emit them as bytea hex (\x...) and map the bytea target type through as-is in pg-type-for, so tables created by pgloader get bytea instead of text.
This branch has not been deployed
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.
Fixes #1782
What happens
In the v4 (Clojure) SQLite source,
read-rowsandread-queryturn each value into a string with(str v). For a BLOB the JDBC driver returns abyte[], so PostgreSQL receives the Java object name ([B@1b2c3d4) instead of the bytes. In create mode the column is also created astext, becausepg-type-forinddl/common.cljhas no case forbytea.The change
source/sqlite.clj: a smalljdbc-value->strhelper writes abyte[]as bytea hex (\x...), the same waymysql.cljandcast.cljalready do. Other values still go through(str v), and NULL stays NULL.ddl/common.clj:byteais passed through inpg-type-for, next touuidandxml, so tables created by pgloader get abyteacolumn.Tests
ddl_test.clj(bytea column definition) andsource/sqlite_test.clj(hex conversion, including an empty array).x'deadbeef',x'00ff7f80005c0a09', an empty blob and NULL: before the change the column istextand holds[B@...; with the change it isbytea, the bytes match, the empty blob has length 0 and NULL is kept. v3 gives the same result as the fixed v4.sqlite-type->pg-testforreal(sqlite_test.clj:42), and is not related to this change.Not checked
Large BLOBs (several MB), the integration suites under
clojure/tests, and user cast rules such astype blob to text.