I'm using the sequel gem to read a SQL server database table.
Before I do that, I connect to the SQL server database using Oracle SQL developer, and the id column shows 1, 2, 3, 4, 5...
The table definition looks like this in SQL Developer:
But when I use the sequel gem to read the table in Ruby, that ID column is a BigDecimal and shows something like 0.1e1. Why is this? If this is an ID, shouldn't it always be integer?
How am I expected to use this field? Am I supposed to call to_i on it to convert it to integer?
A NUMERIC
value on your database is actually a non-integer type. You have a numeric scale here of 0, as in "no decimal part" but it's still considered a BigDecimal
by Ruby with, as on the database, no decimal part.
If you have an integer type, like INT
, then you'll get an Integer in Ruby, but only if. This column could be represented by INT(10)
but it isn't and until you make that alteration Sequel will respect that difference.
It does seem extraordinarily unusual to have a NUMERIC
type identifier. That's probably a mistake.