kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

Oracle FLOAT is mapped to BigDecimal #178

Closed wuarmin closed 6 years ago

wuarmin commented 6 years ago

Hello, I cannot figure out why Oracle FLOAT columns are mapped to ruby BigDecimal class by default. Corresponding to following link https://github.com/kubo/ruby-oci8/blob/master/docs/number-type-mapping.md it should be mapped to Ruby Float class.

I don't know why, but following mapping-change

OCI8::BindType::Mapping[:number] = OCI8::BindType::BasicNumberType

changes the behavior(the FLOAT columns are mapped to Integer- or Float-Class), but I don't know why, because the Oracle Type of my columns are definitely FLOAT.

Maybe somebody can help me? How to achieve a mapping to Ruby Float class. Thx

ZaWertun commented 6 years ago

However, while NUMBER uses decimal precision, BINARY_FLOAT and BINARY_DOUBLE use binary precision.

See: https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1834

wuarmin commented 6 years ago

@ZaWertun Thank you for the info. But I still don't know how to achieve a mapping to ruby-Float-class. Furthermore the mapping-table says that BINARY_FLOATS and BINARY_DOUBLES should also mapped to Float class...

kubo commented 6 years ago
OCI8::BindType::Mapping[:number] = OCI8::BindType::Float

Oracle numbers are converted to Float even when the precision and scale are out of range of Float.

wuarmin commented 6 years ago

Thank you for the clarification!