rails:2074
From: "Akihito Tsukamoto" <tsuka05@g...>
Date: Mon, 19 Mar 2007 19:47:22 +0900
Subject: [rails:2074] sqlite3でバイナリデータが壊れる件
つかもとです。
昨日のRails勉強会@東京で、sqlite3にblob型のカラムに画像などのデータを入れると
壊れる、という件が話にあがっていましたが、string_to_binary, binary_to_string
メソッドで$KCODEの値に従ってマッチングしてしまう事が原因のようです。
下記のパッチで直ったので、本家のtracにもチケット登録しておきました。
--- activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
(revision 6448)
+++ activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
(working copy)
@@ -68,7 +68,7 @@
class SQLiteColumn < Column #:nodoc:
class << self
def string_to_binary(value)
- value.gsub(/\0|\%/) do |b|
+ value.gsub(/\0|\%/n) do |b|
case b
when "\0" then "%00"
when "%" then "%25"
@@ -77,7 +77,7 @@
end
def binary_to_string(value)
- value.gsub(/%00|%25/) do |b|
+ value.gsub(/%00|%25/n) do |b|
case b
when "%00" then "\0"
when "%25" then "%"
--
ML: rails@r...
使い方: http://QuickML.com/