exwiw 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b68b4eed496cf67cbac408c7f1c233a881b9778b46f0f5a67d0ff50b9321e03
4
- data.tar.gz: 521a8cf7d5af0dee4538e407d06d9605d37cb059f5023ee922e11807ff6d1b17
3
+ metadata.gz: 77c28c9a405ca554e6349cc4900a509b255856a19751def01ac46bce748530e6
4
+ data.tar.gz: 40656c295bec322a179e3016a84eb080596868e78c6fb5d95723e809f0505a51
5
5
  SHA512:
6
- metadata.gz: bdd88c3f13879d23a4ecc7c239f22db2c5c5ddbd3bb06b838ae570d48309ba4f2460a6260d9f848da71717dcf43cae0de3b593e3e6e99f43406d700b39e79a37
7
- data.tar.gz: ac2e73630034663ef1ef299fd09925843c086776d10e5998d30758e079a4066f388bdb76672867acacbb57024a5a990336c46e5d8f21d42548862125d1004748
6
+ metadata.gz: a28aa9c5faa8e391f1cfd3de20bf79150173cb41a0578d02883809b186e5ad94d920432cec253893bfdaca339f6a7fbfda1b498263113574c050bc321a68763a
7
+ data.tar.gz: f2b372d7bcf5367ee1c7e5bf10a68f910c1b40d218c133b8e00c12f59be4d4838c7e326ad9de0798c50201f2f7bbed0265cef92fd95cf6597775b8d7fab431f4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.3.5] - 2026-06-01
6
+
7
+ ### Fixed
8
+
9
+ - MySQL export no longer crashes with `IO#write: "\xE4" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)` when a value comes from a binary-collation / `VARBINARY` / `BLOB` column but holds UTF-8 text (e.g. Japanese). Both the `mysql2` and `trilogy` drivers tag such values as `ASCII-8BIT`; writing them to the UTF-8 INSERT file failed inside host processes whose `Encoding.default_internal` is UTF-8 (a Rails app, or `RUBYOPT=-EUTF-8`). The driver-returned strings are now re-tagged UTF-8 (bytes unchanged) so the write is a no-op conversion.
10
+
5
11
  ## [0.3.4] - 2026-05-31
6
12
 
7
13
  ### Changed
@@ -57,7 +57,7 @@ module Exwiw
57
57
  def self.stringify_value(value)
58
58
  case value
59
59
  when nil then nil
60
- when String then value
60
+ when String then normalize_encoding(value)
61
61
  when Time
62
62
  # Emit fractional seconds only when present. A Time can't tell us the
63
63
  # column's declared precision, so a zero fraction on a DATETIME(6)
@@ -76,6 +76,21 @@ module Exwiw
76
76
  end
77
77
  end
78
78
 
79
+ # Re-tag a value string as UTF-8 when it comes back as ASCII-8BIT (BINARY).
80
+ # Both drivers tag values from binary-collation / VARBINARY / BLOB columns
81
+ # as ASCII-8BIT even when the bytes are really UTF-8 text. When exwiw runs
82
+ # inside a host process whose Encoding.default_internal is UTF-8 (e.g. a
83
+ # Rails app, or RUBYOPT=-EUTF-8), IO#write enables conversion, so writing
84
+ # such a binary string carrying multi-byte bytes (e.g. Japanese "\xE4...")
85
+ # to the INSERT file raises "\xE4 from ASCII-8BIT to UTF-8"
86
+ # (Encoding::UndefinedConversionError). Re-tagging makes that write a
87
+ # UTF-8 -> UTF-8 no-op; only the tag changes, the bytes pass through.
88
+ def self.normalize_encoding(str)
89
+ return str unless str.encoding == Encoding::ASCII_8BIT
90
+
91
+ str.dup.force_encoding(Encoding::UTF_8)
92
+ end
93
+
79
94
  attr_reader :driver
80
95
 
81
96
  # `driver:` is mainly a test seam to force a specific driver; in normal use
@@ -92,7 +107,8 @@ module Exwiw
92
107
  case @driver
93
108
  when :mysql2
94
109
  res = raw.query(sql, cast: false, as: :array)
95
- Result.new(res.fields, res.to_a)
110
+ rows = res.to_a.map { |row| row.map { |value| self.class.stringify_value(value) } }
111
+ Result.new(res.fields, rows)
96
112
  when :trilogy
97
113
  res = raw.query(sql)
98
114
  rows = res.rows.map { |row| row.map { |value| self.class.stringify_value(value) } }
data/lib/exwiw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia