From c72b59d31b5747499196fd04a45fb2573b2964e9 Mon Sep 17 00:00:00 2001 From: Tilmann Singer Date: Mon, 16 May 2011 23:26:36 +0200 Subject: [PATCH] Add failing test for postgresql numeric without scale and precision --- test/models/data_types.rb | 1 + test/postgres_numeric_test.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/postgres_numeric_test.rb diff --git a/test/models/data_types.rb b/test/models/data_types.rb index 401bf347b..3cd721f9f 100644 --- a/test/models/data_types.rb +++ b/test/models/data_types.rb @@ -10,6 +10,7 @@ def self.up t.column :sample_time, :time t.column :sample_decimal, :decimal, :precision => 15, :scale => 0 t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2 + t.column :sample_default_decimal, :decimal t.column :sample_float, :float t.column :sample_binary, :binary t.column :sample_boolean, :boolean diff --git a/test/postgres_numeric_test.rb b/test/postgres_numeric_test.rb new file mode 100644 index 000000000..4c4cd9d09 --- /dev/null +++ b/test/postgres_numeric_test.rb @@ -0,0 +1,25 @@ +# To run this script, set up the following postgres user and database: +# +# sudo -u postgres createuser -D -A -P blog +# sudo -u postgres createdb -O blog weblog_development +# + +require 'jdbc_common' +require 'db/postgres' + +class PostgresNumericTest < Test::Unit::TestCase + def setup + DbTypeMigration.up + end + + def teardown + DbTypeMigration.down + end + + def test_should_keep_fractional_part + expected = 7.3 + actual = DbType.create(:sample_default_decimal => expected).sample_default_decimal + + assert_equal expected, actual + end +end