Closed klcompt closed 13 years ago
I haven't had time to look into this yet, but I wanted to thank you for the extremely thorough bug report. I plan to look into the type handling in ARJDBC in the next couple days, so I'll add these tests at that point.
Unfortunately, this is a bug in the underlying JDBC adapter. I've filed a bug upstream.
Thank you for the effort put in to this issue.
Use DbType#sample_small_decimal and create two records: one with a sample_small_decimal value of 3.14 and another with value 1.0.
If you give an order clause that will force the record with value as 1.0 to be the first in the resultset you will find that the decimal portion of 3.14 gets truncated to 3.0.
I have duplicated this issue on a windows box and a mac box.
Mac box details:
jruby 1.6.2 (ruby-1.8.7-p330) (2011-05-23 e2ea975) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [darwin-x86_64-java]
bundle list: Kevin-Comptons-MacBook-Pro:activerecord-jdbc-adapter kevin$ jruby -S bundle list Gems included by the bundle:
Test to demostrate:
running: $ rake test_sqlite3
sqlite3_simple_test.rb changes denoted by # KLC Added below:
class SQLite3TypeConversionTest < Test::Unit::TestCase TEST_TIME = Time.at(1169964202) TEST_BINARY = "Some random binary data % \0 and then some" def setup DbTypeMigration.up DbType.create( :sample_timestamp => TEST_TIME, :sample_datetime => TEST_TIME, :sample_time => TEST_TIME, :sample_date => TEST_TIME, :sample_decimal => JInteger::MAX_VALUE + 1, :sample_small_decimal => 3.14, :sample_binary => TEST_BINARY)
KLC Added
KLC Added end
end
def teardown DbTypeMigration.down end
..... existing tests ...
KLC Added
def test_small_decimal types = DbType.find(:all) # relying on natural ordering which would bring 3.14 back as first record assert_equal(3.14, types[0].sample_small_decimal) # PASSES as expected assert_equal(1.0, types[1].sample_small_decimal) end
def test_small_decimal_with_ordering types = DbType.find(:all, :order => "sample_small_decimal asc") assert_equal(1.0, types[0].sample_small_decimal) assert_equal(3.14, types[1].sample_small_decimal) # FAILS due to a truncated value of 3.0 end
KLC Added end
.... rest of test ...
end