This project is archived and is in readonly mode.
Decimal column with zero scale dumped as integer column
-
Michael Koziarski
Isn't the real problem here that column.type for that column is returning integer rather than decimal?
The fix should probably be there rather than just in the dumper?
-
Giles Alexander
I tried that, and it caused a lot of test failures. There's an optimisation in ActiveRecord to represent decimal columns with a scale of 0 as integers. This is a pretty good optimisation, that I actually want, and it's described in the documentation.
This just changes the dumper to notice when that optimisation has been applied.
-
Repository
- State changed from new to committed
(from [532219fd091837a9312a301c74e0fbf06abab3a8]) Schema dumper now records scale 0 decimal columns as decimal not integer.
The schema dumper would dump out any decimal or numeric column that had a zero
scale as an integer column. This will cause problems for very large precision
columns on some DBMSs, particularly PostgreSQL. It also looks strange to see
your column change type after moving through schema.rb.Signed-off-by: Michael Koziarski michael@koziarski.com
[#2741 Decimal column with zero scale dumped as integer column state:committed] http://github.com/rails/rails/commit/532219fd091837a9312a301c74e0fb... -
Michael Koziarski
I had to change the precision down to 55 in the tests as mysql (at least on my mac) doesn't support precisions that high.
Does it still look ok?
-
Giles Alexander
Thanks. Yes, that still looks ok.
