1

I just recently made the switch over to PostgreSQL.. and just wondering about this issue:

PG::Error: ERROR:  column "bathrooms" is of type double precision but expression is of type    character varying at character 161
HINT:  You will need to rewrite or cast the expression.
: INSERT INTO "properties" ("address", "bathrooms", "bedrooms", "city", "country", "created_at",     "description", "name", "state", "updated_at", "zip") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id"

Migration looks like this:

class CreateProperties < ActiveRecord::Migration
 def change
   create_table :properties do |t|
   t.string :name
   t.string :address
   t.string :city
   t.string :state
   t.string :zip
   t.string :country
   t.float :bedrooms
   t.float :bathrooms
   t.string :country
   t.text :description

   t.timestamps
  end
 end
end
4

1 回答 1

1

我将浮点数切换为十进制,现在 PostgreSQL 似乎可以使用隐式转换了?

无论哪种方式错误都消失了,谢谢

于 2013-01-15T19:21:36.657 回答