Closed stci closed 14 years ago
Which Ruby version are you using and on which platform? On my Mac OS X 10.6 and standard ruby 1.8.7 (2009-06-08 patchlevel 173) all expectations plsql.float_test.first()[:amount].should == amount are passing. So I assume that on your Ruby version there is some issue when comparing BigDecimal values (what ruby-plsql returns from NUMBER columns) and constant Float values.
But I found out very strange issue when multiplying BigDecimal with Integer: (BigDecimal('100.76')*100).to_f => 17600.0
So better do not do arithmetics with BigDecimals and Integers :)
Hi Raimonds,
We are using ruby version is 1.8.6 (2007-03-13 patchlevel 0).
Our admin proposed me to check classes of each value. Value from DB has BigDecimal type and constant value is Float. I've found that there is conversion method "to_d" to convert Float to BigDecimal (in bigdecimal library - util.rb). When I convert constant value (Float) using to_d to BigDecimal comparison will pass.
I've checked your arithmetics example and it works without problem for multiplying integer and BigDecimal values.
Thanks Stefan
OK, then I'm closing the issue. If possible I recommend to upgrade to Ruby 1.8.7 as I nowadays mostly test with this version.
Hi, I've found this interesting tool for PL/SQL unit tests and I'm trying to learn its usage.
During setting my unit tests I noticed strange behavior when comparing decimal numbers - one number read from DB and constant.
Here is small example: 1) first create table in SQL create table float_test (amount number(12,2))
2) test description
After running this test I've got result that for case number 3 failed on line where comparing clear values. Part of output: 1) 'Check decimal number comparison should compare decimal numbers [case: 3]' FAILED expected: 1000.76, got: 1000.76 (using ==)
Additional info:
Stefan