From 2a12b56841bd6fd3998050e7677a1b2c08257479 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 8 Jul 2006 20:35:56 +0000 Subject: r4704@asus: jeremy | 2006-06-27 12:00:19 -0700 decimal r4705@asus: jeremy | 2006-06-27 12:20:47 -0700 current_adapter? checks whether any of its arguments is the name of the current adapter class r4834@asus: jeremy | 2006-07-08 13:08:24 -0700 Room to float. r4835@asus: jeremy | 2006-07-08 13:09:18 -0700 Give lock test a few chances. r4836@asus: jeremy | 2006-07-08 13:12:05 -0700 Numeric and decimal columns map to BigDecimal instead of Float. Those with scale 0 map to Integer. Closes #5454. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4596 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../test/fixtures/db_definitions/db2.drop.sql | 1 + activerecord/test/fixtures/db_definitions/db2.sql | 9 ++++++++ .../test/fixtures/db_definitions/firebird.drop.sql | 2 ++ .../test/fixtures/db_definitions/firebird.sql | 12 ++++++++++ .../fixtures/db_definitions/frontbase.drop.sql | 1 + .../test/fixtures/db_definitions/frontbase.sql | 11 +++++++++ .../test/fixtures/db_definitions/mysql.drop.sql | 1 + .../test/fixtures/db_definitions/mysql.sql | 9 ++++++++ .../test/fixtures/db_definitions/openbase.sql | 14 ++++++++++- .../test/fixtures/db_definitions/oracle.drop.sql | 2 ++ .../test/fixtures/db_definitions/oracle.sql | 10 ++++++++ .../fixtures/db_definitions/postgresql.drop.sql | 4 +++- .../test/fixtures/db_definitions/postgresql.sql | 12 +++++++++- .../test/fixtures/db_definitions/sqlite.drop.sql | 1 + .../test/fixtures/db_definitions/sqlite.sql | 11 ++++++++- .../fixtures/db_definitions/sqlserver.drop.sql | 2 ++ .../test/fixtures/db_definitions/sqlserver.sql | 27 ++++++++++++++++++++++ .../test/fixtures/db_definitions/sybase.drop.sql | 1 + .../test/fixtures/db_definitions/sybase.sql | 11 ++++++++- .../1_give_me_big_numbers.rb | 15 ++++++++++++ 20 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb (limited to 'activerecord/test/fixtures') diff --git a/activerecord/test/fixtures/db_definitions/db2.drop.sql b/activerecord/test/fixtures/db_definitions/db2.drop.sql index c5b32bb9fc..50cffe3b47 100644 --- a/activerecord/test/fixtures/db_definitions/db2.drop.sql +++ b/activerecord/test/fixtures/db_definitions/db2.drop.sql @@ -28,3 +28,4 @@ DROP TABLE fk_test_has_pk; DROP TABLE fk_test_has_fk; DROP TABLE keyboards; DROP TABLE legacy_things; +DROP TABLE numeric_data; diff --git a/activerecord/test/fixtures/db_definitions/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql index 2f67e9ce53..ee76fc4d05 100644 --- a/activerecord/test/fixtures/db_definitions/db2.sql +++ b/activerecord/test/fixtures/db_definitions/db2.sql @@ -215,3 +215,12 @@ CREATE TABLE legacy_things ( version INT DEFAULT 0, PRIMARY KEY (id) ); + +CREATE TABLE numeric_data ( + id INT NOT NULL PRIMARY KEY, + bank_balance DECIMAL(10,2), + big_bank_balance DECIMAL(15,2), + world_population DECIMAL(10), + my_house_population DECIMAL(2), + decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78 +); diff --git a/activerecord/test/fixtures/db_definitions/firebird.drop.sql b/activerecord/test/fixtures/db_definitions/firebird.drop.sql index 807361ed45..2e43243af7 100644 --- a/activerecord/test/fixtures/db_definitions/firebird.drop.sql +++ b/activerecord/test/fixtures/db_definitions/firebird.drop.sql @@ -29,6 +29,7 @@ DROP TABLE fk_test_has_pk; DROP TABLE keyboards; DROP TABLE defaults; DROP TABLE legacy_things; +DROP TABLE numeric_data; DROP DOMAIN D_BOOLEAN; @@ -57,3 +58,4 @@ DROP GENERATOR categories_seq; DROP GENERATOR keyboards_seq; DROP GENERATOR defaults_seq; DROP GENERATOR legacy_things_seq; +DROP GENERATOR numeric_data_seq; diff --git a/activerecord/test/fixtures/db_definitions/firebird.sql b/activerecord/test/fixtures/db_definitions/firebird.sql index c523bfe7bb..8ca0bf6222 100644 --- a/activerecord/test/fixtures/db_definitions/firebird.sql +++ b/activerecord/test/fixtures/db_definitions/firebird.sql @@ -283,3 +283,15 @@ CREATE TABLE legacy_things ( ); CREATE GENERATOR legacy_things_seq; SET GENERATOR legacy_things_seq TO 10000; + +CREATE TABLE numeric_data ( + id BIGINT NOT NULL, + bank_balance DECIMAL(10,2), + big_bank_balance DECIMAL(15,2), + world_population DECIMAL(10), + my_house_population DECIMAL(2), + decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78, + PRIMARY KEY (id) +); +CREATE GENERATOR numeric_data_seq; +SET GENERATOR numeric_data_seq TO 10000; diff --git a/activerecord/test/fixtures/db_definitions/frontbase.drop.sql b/activerecord/test/fixtures/db_definitions/frontbase.drop.sql index 231af7895c..5fc64f769b 100644 --- a/activerecord/test/fixtures/db_definitions/frontbase.drop.sql +++ b/activerecord/test/fixtures/db_definitions/frontbase.drop.sql @@ -28,3 +28,4 @@ DROP TABLE fk_test_has_fk CASCADE; DROP TABLE fk_test_has_pk CASCADE; DROP TABLE keyboards CASCADE; DROP TABLE legacy_things CASCADE; +DROP TABLE numeric_data CASCADE; diff --git a/activerecord/test/fixtures/db_definitions/frontbase.sql b/activerecord/test/fixtures/db_definitions/frontbase.sql index 13ce65297b..e102f65aa7 100644 --- a/activerecord/test/fixtures/db_definitions/frontbase.sql +++ b/activerecord/test/fixtures/db_definitions/frontbase.sql @@ -249,3 +249,14 @@ create table "legacy_things" primary key ("id") ); SET UNIQUE FOR legacy_things(id); + +CREATE TABLE "numeric_data" ( + "id" integer NOT NULL + "bank_balance" DECIMAL(10,2), + "big_bank_balance" DECIMAL(15,2), + "world_population" DECIMAL(10), + "my_house_population" DECIMAL(2), + "decimal_number_with_default" DECIMAL(3,2) DEFAULT 2.78, + primary key ("id") +); +SET UNIQUE FOR numeric_data(id); diff --git a/activerecord/test/fixtures/db_definitions/mysql.drop.sql b/activerecord/test/fixtures/db_definitions/mysql.drop.sql index 14df93fd2a..cb6a870a7c 100644 --- a/activerecord/test/fixtures/db_definitions/mysql.drop.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.drop.sql @@ -28,3 +28,4 @@ DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; DROP TABLE keyboards; DROP TABLE legacy_things; +DROP TABLE numeric_data; diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index 4107155450..61ba43e954 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -217,3 +217,12 @@ CREATE TABLE `legacy_things` ( `version` int(11) NOT NULL default 0, PRIMARY KEY (`id`) ) TYPE=InnoDB; + +CREATE TABLE `numeric_data` ( + `id` INTEGER NOT NULL PRIMARY KEY, + `bank_balance` decimal(10,2), + `big_bank_balance` decimal(15,2), + `world_population` decimal(10), + `my_house_population` decimal(2), + `decimal_number_with_default` decimal(3,2) DEFAULT 2.78 +) TYPE=InnoDB; diff --git a/activerecord/test/fixtures/db_definitions/openbase.sql b/activerecord/test/fixtures/db_definitions/openbase.sql index 9ca1a7d06e..c3da2efee6 100644 --- a/activerecord/test/fixtures/db_definitions/openbase.sql +++ b/activerecord/test/fixtures/db_definitions/openbase.sql @@ -279,4 +279,16 @@ CREATE TABLE legacy_things ( ) go CREATE PRIMARY KEY legacy_things (id) -go \ No newline at end of file +go + +CREATE TABLE numeric_data ( + id INTEGER NOT NULL DEFAULT _rowid, + bank_balance DECIMAL(10,2), + big_bank_balance DECIMAL(15,2), + world_population DECIMAL(10), + my_house_population DECIMAL(2), + decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78 +); +go +CREATE PRIMARY KEY numeric_data (id) +go diff --git a/activerecord/test/fixtures/db_definitions/oracle.drop.sql b/activerecord/test/fixtures/db_definitions/oracle.drop.sql index 4d4ddb835d..6fa01cdf51 100644 --- a/activerecord/test/fixtures/db_definitions/oracle.drop.sql +++ b/activerecord/test/fixtures/db_definitions/oracle.drop.sql @@ -29,6 +29,7 @@ drop table fk_test_has_pk; drop table fk_test_has_fk; drop table keyboards; drop table legacy_things; +drop table numeric_data; drop sequence accounts_seq; drop sequence funny_jokes_seq; @@ -59,3 +60,4 @@ drop sequence fk_test_has_pk_seq; drop sequence fk_test_has_fk_seq; drop sequence keyboards_seq; drop sequence legacy_things_seq; +drop sequence numeric_data_seq; diff --git a/activerecord/test/fixtures/db_definitions/oracle.sql b/activerecord/test/fixtures/db_definitions/oracle.sql index 48d6bdf073..ccf472c905 100644 --- a/activerecord/test/fixtures/db_definitions/oracle.sql +++ b/activerecord/test/fixtures/db_definitions/oracle.sql @@ -290,3 +290,13 @@ create table legacy_things ( version integer default 0 ); create sequence legacy_things_seq minvalue 10000; + +CREATE TABLE numeric_data ( + id integer NOT NULL PRIMARY KEY, + bank_balance decimal(10,2), + big_bank_balance decimal(15,2), + world_population decimal(10), + my_house_population decimal(2), + decimal_number_with_default decimal(3,2) DEFAULT 2.78 +); +create sequence numeric_data_seq minvalue 10000; diff --git a/activerecord/test/fixtures/db_definitions/postgresql.drop.sql b/activerecord/test/fixtures/db_definitions/postgresql.drop.sql index 2662839214..4910b0ecee 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.drop.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.drop.sql @@ -1,5 +1,5 @@ -DROP SEQUENCE accounts_id_seq; DROP TABLE accounts; +DROP SEQUENCE accounts_id_seq; DROP TABLE funny_jokes; DROP TABLE companies; DROP SEQUENCE companies_nonstd_seq; @@ -32,3 +32,5 @@ DROP TABLE fk_test_has_pk; DROP TABLE geometrics; DROP TABLE keyboards; DROP TABLE legacy_things; +DROP TABLE numeric_data; +DROP TABLE column_data; diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index 175e8494bb..ce2c775aba 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -118,7 +118,8 @@ CREATE TABLE defaults ( char2 character varying(50) default 'a varchar field', char3 text default 'a text field', positive_integer integer default 1, - negative_integer integer default -1 + negative_integer integer default -1, + decimal_number decimal(3,2) default 2.78 ); CREATE TABLE auto_id_tests ( @@ -246,3 +247,12 @@ CREATE TABLE legacy_things ( tps_report_number integer, version integer default 0 ); + +CREATE TABLE numeric_data ( + id serial primary key, + bank_balance decimal(10,2), + big_bank_balance decimal(15,2), + world_population decimal(10), + my_house_population decimal(2), + decimal_number_with_default decimal(3,2) default 2.78 +); diff --git a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql index 14df93fd2a..cb6a870a7c 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql @@ -28,3 +28,4 @@ DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; DROP TABLE keyboards; DROP TABLE legacy_things; +DROP TABLE numeric_data; diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql index 5a7fec3d7e..8f89c419a1 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.sql @@ -198,4 +198,13 @@ CREATE TABLE 'legacy_things' ( 'id' INTEGER NOT NULL PRIMARY KEY, 'tps_report_number' INTEGER DEFAULT NULL, 'version' INTEGER NOT NULL DEFAULT 0 -) +); + +CREATE TABLE 'numeric_data' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'bank_balance' DECIMAL(10,2), + 'big_bank_balance' DECIMAL(15,2), + 'world_population' DECIMAL(10), + 'my_house_population' DECIMAL(2), + 'decimal_number_with_default' DECIMAL(3,2) DEFAULT 2.78 +); diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql index ea14697bd3..b157d7c0a7 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql @@ -10,6 +10,7 @@ DROP TABLE orders; DROP TABLE movies; DROP TABLE subscribers; DROP TABLE booleantests; +DROP TABLE defaults; DROP TABLE auto_id_tests; DROP TABLE entrants; DROP TABLE colnametests; @@ -28,3 +29,4 @@ DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; DROP TABLE keyboards; DROP TABLE legacy_things; +DROP TABLE numeric_data; diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index acbcaa1384..7b6f1d7afd 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -88,6 +88,24 @@ CREATE TABLE booleantests ( value bit default NULL ); +CREATE TABLE defaults ( + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, +-- these brought from the PostgreSQL defaults_test.rb but +-- tests only exist for integers and decimals, currently +-- modified_date date default CURRENT_DATE, +-- modified_date_function date default now(), +-- fixed_date date default '2004-01-01', +-- modified_time timestamp default CURRENT_TIMESTAMP, +-- modified_time_function timestamp default now(), +-- fixed_time timestamp default '2004-01-01 00:00:00.000000-00', +-- char1 char(1) default 'Y', +-- char2 character varying(50) default 'a varchar field', +-- char3 text default 'a text field', + positive_integer integer default 1, + negative_integer integer default -1, + decimal_number decimal(3,2) default 2.78 +); + CREATE TABLE auto_id_tests ( auto_id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, value int default NULL @@ -201,3 +219,12 @@ CREATE TABLE legacy_things ( version int default 0, PRIMARY KEY (id) ); + +CREATE TABLE numeric_data ( + id int NOT NULL IDENTITY(1, 1), + bank_balance decimal(10,2), + big_bank_balance decimal(15,2), + world_population decimal(10), + my_house_population decimal(2), + decimal_number_with_default decimal(3,2) DEFAULT 2.78 +); diff --git a/activerecord/test/fixtures/db_definitions/sybase.drop.sql b/activerecord/test/fixtures/db_definitions/sybase.drop.sql index f843a80f7a..fa51eefeeb 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.drop.sql @@ -28,4 +28,5 @@ DROP TABLE fk_test_has_fk DROP TABLE fk_test_has_pk DROP TABLE keyboards DROP TABLE legacy_things +DROP TABLE numeric_data go diff --git a/activerecord/test/fixtures/db_definitions/sybase.sql b/activerecord/test/fixtures/db_definitions/sybase.sql index 98022f8887..79c7b940b5 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.sql @@ -200,5 +200,14 @@ CREATE TABLE legacy_things ( version int default 0, ) -go +CREATE TABLE numeric_data ( + id numeric((9,0) IDENTITY PRIMARY KEY, + bank_balance numeric(10,2), + big_bank_balance numeric(15,2), + world_population numeric(10), + my_house_population numeric(2), + decimal_number_with_default numeric(3,2) DEFAULT 2.78 +) + +go diff --git a/activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb b/activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb new file mode 100644 index 0000000000..0aed7cbd84 --- /dev/null +++ b/activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb @@ -0,0 +1,15 @@ +class GiveMeBigNumbers < ActiveRecord::Migration + def self.up + create_table :big_numbers do |table| + table.column :bank_balance, :decimal, :precision => 10, :scale => 2 + table.column :big_bank_balance, :decimal, :precision => 15, :scale => 2 + table.column :world_population, :decimal, :precision => 10 + table.column :my_house_population, :decimal, :precision => 2 + table.column :value_of_e, :decimal + end + end + + def self.down + drop_table :big_numbers + end +end -- cgit v1.2.3