diff options
author | Jamis Buck <jamis@37signals.com> | 2005-09-25 15:49:35 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-09-25 15:49:35 +0000 |
commit | ea654654226924f9b900e7981fdbdbd452ca15d8 (patch) | |
tree | 606aefd628d9e31eababdefc59b02c3b29d51867 /activerecord/test | |
parent | e7059fd28191a77d53e66389f8df5b22036699e8 (diff) | |
download | rails-ea654654226924f9b900e7981fdbdbd452ca15d8.tar.gz rails-ea654654226924f9b900e7981fdbdbd452ca15d8.tar.bz2 rails-ea654654226924f9b900e7981fdbdbd452ca15d8.zip |
Standardize the interpretation of boolean columns in the Mysql and Sqlite adapters. (Use MysqlAdapter.emulate_booleans = false to disable this behavior)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2335 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/fixtures/db_definitions/mysql.sql | 4 | ||||
-rw-r--r-- | activerecord/test/migration_test.rb | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index d581ee3ae8..393a6e808e 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -26,7 +26,7 @@ CREATE TABLE `topics` ( `bonus_time` time default NULL, `last_read` date default NULL, `content` text, - `approved` tinyint(1) default 1, + `approved` tinyint default 1, `replies_count` int(11) default 0, `parent_id` int(11) default NULL, `type` varchar(50) default NULL, @@ -190,4 +190,4 @@ CREATE TABLE `fk_test_has_fk` ( `fk_id` INTEGER NOT NULL, FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`) -) TYPE=InnoDB;
\ No newline at end of file +) TYPE=InnoDB; diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 502348877c..b24b7a7d44 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -68,6 +68,29 @@ if ActiveRecord::Base.connection.supports_migrations? ensure Person.connection.drop_table :testings rescue nil end + + def test_create_table_with_defaults + Person.connection.create_table :testings do |t| + t.column :one, :string, :default => "hello" + t.column :two, :boolean, :default => true + t.column :three, :boolean, :default => false + t.column :four, :integer, :default => 1 + end + + columns = Person.connection.columns(:testings) + one = columns.detect { |c| c.name == "one" } + two = columns.detect { |c| c.name == "two" } + three = columns.detect { |c| c.name == "three" } + four = columns.detect { |c| c.name == "four" } + + assert_equal "hello", one.default + assert_equal true, two.default + assert_equal false, three.default + assert_equal 1, four.default + + ensure + Person.connection.drop_table :testings rescue nil + end def test_add_column_not_null Person.connection.create_table :testings do |t| |