EUREKA.

I have debugged the thing very early this morning.
It seems that the file mysql.rb coming with Ruby/MySQL 0.2.5 has an error,
converting \032 into "\Z" instead of "\\Z" I think.
With this correction, the blob_test.rb from Ruby DBI works all right.

  def escape_string(str)
    str.gsub(/([\0\n\r\032\'\"\\])/) do
      case $1
      when "\0" then "\\0"
      when "\n" then "\\n"
      when "\r" then "\\r"
-      when "\032" then "\Z"
+      when "\032" then "\\Z"
      else "\\"+$1
      end
    end
  end
  alias :quote :escape_string

Je


----- Original Message ----- 
From: "Jerome Hauss" <jhauss / gfi.fr>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Wednesday, October 13, 2004 5:04 PM
Subject: DBI Mysql storing DBI:binary, trouble with character 26


Hello,

Is there any solution to get binary data stored in a correct way into a blob
in a Mysql database on a win32 platform ?

I am trying to store data from Ruby into a mysql LONGBLOB column, on a Win32
platform (Windows 2000, dbi 0.0.23 with Ruby/MySQL 0.2.5 interface, ruby
1.8.10-1, mysql 4.0.21)
From ruby-dbi-all-0.0.23.tar.gz archive, I have tested
ruby-dbi-all\lib\dbd_mysql\test\blob_test.rb, and it appears character 26
(octal 032) (hexa 1A) (CTRL-Z) stored in a blob is retrieved as character 90
(octal 132) (hexa 5A) (Z itself). All tests from blob_test.rb are "wrong".
Yet when I use for instance phpMyAdmin to store data without Ruby, I can
later with Ruby retrieve characters 26 correctly.
So the problem seems to happen only when storing into the blob, not when
retrieving.

Any solution ?

Je