1

t.decimal :hogeと指定した場合の最大値と最小値はいくらでしょうか?

Out of range value for column

と出てしまうので、バリデーションをかけたいです。(わざわざ最大値と最小値にあわせることなくアプリ固有で恣意的に決めてしまってもよいとは思いますが...)

1 件の回答 1

1

decimalの場合の最大値、最小値はデータベースによります。

Please be aware of different RDBMS implementations behavior with :decimal columns:
The SQL standard says the default scale should be 0, :scale <= :precision, and makes no comments about the requirements of :precision.

  • MySQL: :precision [1..63], :scale [0..30]. Default is (10,0).
  • PostgreSQL: :precision [1..infinity], :scale [0..infinity]. No default.
  • SQLite2: Any :precision and :scale may be used. Internal storage as strings. No default.
  • SQLite3: No restrictions on :precision and :scale, but the maximum supported :precision is 16. No default.
  • Oracle: :precision [1..38], :scale [-84..127]. Default is (38,0).
  • DB2: :precision [1..63], :scale [0..62]. Default unknown.
  • SqlServer?: :precision [1..38], :scale [0..38]. Default (38,0).

http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。