getBytes returns nil instead of an 0 length byte[] instance in
jdbc-sqlite3 3.8.7. Add a wasNull check to catch this an return
an empty blob in that case, idea from Karol Bucek.
Details:
https://github.com/jruby/activerecord-jdbc-adapter/issues/605
https://bitbucket.org/xerial/sqlite-jdbc/issue/155
=== HEAD
+* Work around regression in jdbc-sqlite3 3.8.7 where empty blobs are returned as nil (jeremyevans)
+
* Work around regression in jdbc-sqlite3 3.8.7 when using JDBC getDate method for date parsing (jeremyevans)
* Make Model#update_or_create return object if existing object exists but updates are not necessary (contentfree) (#916)
end
# Use getLong instead of getInt for converting integers on SQLite, since SQLite does not enforce a limit of 2**32.
+ # Work around regressions in jdbc-sqlite 3.8.7 for date and blob types.
def setup_type_convertor_map
super
@type_convertor_map[Java::JavaSQL::Types::INTEGER] = @type_convertor_map[Java::JavaSQL::Types::BIGINT]
Sequel.string_to_date(v)
end
end
+ @type_convertor_map[Java::JavaSQL::Types::BLOB] = lambda do |r, i|
+ if v = r.getBytes(i)
+ Sequel::SQL::Blob.new(String.from_java_bytes(v))
+ elsif !r.wasNull
+ Sequel::SQL::Blob.new('')
+ end
+ end
end
end
end