在`remote_ip`列上为`string`类型插入的二进制数据?

时间:2012-10-16 10:10:22

标签: ruby-on-rails-3 sqlite

Binary data inserted for字符串type on column ...的含义是什么?

当SQLite表中的loggin远程IP地址时,调试控制台中会显示一条消息:

Started GET "/test?name=abcde" for 127.0.0.1 at 2012-10-16 18:02:01 +0800
Processing by TestController#index as HTML
  Parameters: {"name"=>"abcde"}
   (0.1ms)  begin transaction
Binary data inserted for `string` type on column `query`
Binary data inserted for `string` type on column `remote_ip`
  SQL (0.6ms)  INSERT INTO "requests" ("controller", "query", "remote_ip") VALUES (?, ?, ?)  [["controller", "test"], ["query", "name=abcde"], ["remote_ip", "127.0.0.1"]]
   (2.5ms)  commit transaction

该表定义为:

class CreateRequests < ActiveRecord::Migration
  def change
    create_table :requests do |t|
      t.string   :controller, :limit => 128
      t.string   :remote_ip,  :limit => 128
      t.string   :query,      :limit => 2048
    end
  end
end

配置:

OS X Lion
ruby 1.9.3p194 
Rails 3.2.8
sqlite3 (1.3.6)
sqlite3-ruby (1.3.2)

1 个答案:

答案 0 :(得分:3)

这意味着您的Ruby字符串标记有一些非默认编码:
(见https://github.com/luislavena/sqlite3-ruby/issues/45