aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-12-03 04:19:27 +1030
committerGitHub <noreply@github.com>2017-12-03 04:19:27 +1030
commit6a7787218b8d75913b58d7bed198495e8d29e34e (patch)
treeec324f35f9dd2d839016579855c2dac0a6dde90a /activerecord/test/cases
parent4c4d092431f45471f90badb81eaa2011843cc39b (diff)
parentdd6338a0699f2301d4b2fc8653688b4c4183cee5 (diff)
downloadrails-6a7787218b8d75913b58d7bed198495e8d29e34e.tar.gz
rails-6a7787218b8d75913b58d7bed198495e8d29e34e.tar.bz2
rails-6a7787218b8d75913b58d7bed198495e8d29e34e.zip
Merge pull request #31230 from dinahshi/postgresql_extract_sql
Extract sql fragment generators from PostgreSQL adapter
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/adapters/mysql2/connection_test.rb4
-rw-r--r--activerecord/test/cases/migration/compatibility_test.rb17
2 files changed, 19 insertions, 2 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb
index e61c70848a..13b4096671 100644
--- a/activerecord/test/cases/adapters/mysql2/connection_test.rb
+++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb
@@ -174,10 +174,10 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase
assert_equal "SCHEMA", @subscriber.logged[0][1]
end
- def test_logs_name_rename_column_sql
+ def test_logs_name_rename_column_for_alter
@connection.execute "CREATE TABLE `bar_baz` (`foo` varchar(255))"
@subscriber.logged.clear
- @connection.send(:rename_column_sql, "bar_baz", "foo", "foo2")
+ @connection.send(:rename_column_for_alter, "bar_baz", "foo", "foo2")
assert_equal "SCHEMA", @subscriber.logged[0][1]
ensure
@connection.execute "DROP TABLE `bar_baz`"
diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb
index 2fef2f796e..0fd55e6ae4 100644
--- a/activerecord/test/cases/migration/compatibility_test.rb
+++ b/activerecord/test/cases/migration/compatibility_test.rb
@@ -126,6 +126,23 @@ module ActiveRecord
end
assert_match(/LegacyMigration < ActiveRecord::Migration\[4\.2\]/, e.message)
end
+
+ if current_adapter?(:PostgreSQLAdapter)
+ class Testing < ActiveRecord::Base
+ end
+
+ def test_legacy_change_column_with_null_executes_update
+ migration = Class.new(ActiveRecord::Migration[5.1]) {
+ def migrate(x)
+ change_column :testings, :foo, :string, null: false, default: "foobar"
+ end
+ }.new
+
+ t = Testing.create!
+ ActiveRecord::Migrator.new(:up, [migration]).migrate
+ assert_equal ["foobar"], Testing.all.map(&:foo)
+ end
+ end
end
end
end