rowland / fb

Firebird Extension Library for Ruby
64 stars 35 forks source link

reading of decimal(18, 5) gets corrupted #35

Closed vizcay closed 9 years ago

vizcay commented 9 years ago

I've been caught by a very strange bug at my production server related to decimal fields:

How to reproduce (32bit architecture needed):

require 'fb'
include Fb
db = Database.new(:database => "#{File.expand_path(File.dirname(__FILE__))}/test.fdb", :username => 'sysdba', :password => 'masterkey')
conn = db.connect rescue db.create.connect
conn.execute("create table TEST (ID int not null primary key, N decimal(18, 5))") if !conn.table_names.include?("TEST")
conn.execute("delete from TEST")
conn.execute("insert into TEST values (?, ?)", 1, 50000)
puts "50000 = #{conn.query(:hash, "select * from TEST").first['N']} ?"

At my production server I get: "50000 = 7050.32704 ?" and at my dev machine of course: "50000 = 50000.0 ?"

rowland commented 9 years ago

Fixed. Thanks for the report.

vizcay commented 9 years ago

Thanks Rowland!