1

私は最近PostgreSQLに切り替えました..そしてこの問題について疑問に思っています:

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"

移行は次のようになります。

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

floatを10進数に切り替えましたが、PostgreSQLはその暗黙のキャストで問題ないようです。

いずれにせよ、エラーはなくなりました、ありがとう

于 2013-01-15T19:21:36.657 に答える