diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-03 21:05:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-04 22:15:15 +0900 |
commit | e612a47aac560cd2a908b6a624bb17057a09f0b8 (patch) | |
tree | deff94b06b78c5edb2b249ee4797eef744b99449 | |
parent | a72473f0320cc58bea1b47c856c62f015d5da82b (diff) | |
download | rails-e612a47aac560cd2a908b6a624bb17057a09f0b8.tar.gz rails-e612a47aac560cd2a908b6a624bb17057a09f0b8.tar.bz2 rails-e612a47aac560cd2a908b6a624bb17057a09f0b8.zip |
Deprecate `valid_alter_table_type?` in sqlite3 adapter
This method which is used only in the internal was introduced in
ac384820 and was renamed in #17579. It does not need to be exposed.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 19 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb | 4 |
2 files changed, 16 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 441c7cd28f..d4f5bd16ac 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -290,19 +290,18 @@ module ActiveRecord rename_table_indexes(table_name, new_name) end - # See: https://www.sqlite.org/lang_altertable.html - # SQLite has an additional restriction on the ALTER TABLE statement - def valid_alter_table_type?(type) - type.to_sym != :primary_key + def valid_alter_table_type?(type, options = {}) + !invalid_alter_table_type?(type, options) end + deprecate :valid_alter_table_type? def add_column(table_name, column_name, type, options = {}) #:nodoc: - if valid_alter_table_type?(type) && !options[:primary_key] - super(table_name, column_name, type, options) - else + if invalid_alter_table_type?(type, options) alter_table(table_name) do |definition| definition.column(column_name, type, options) end + else + super end end @@ -386,6 +385,12 @@ module ActiveRecord end alias column_definitions table_structure + # See: https://www.sqlite.org/lang_altertable.html + # SQLite has an additional restriction on the ALTER TABLE statement + def invalid_alter_table_type?(type, options) + type.to_sym == :primary_key || options[:primary_key] + end + def alter_table(table_name, options = {}) altered_table_name = "a#{table_name}" caller = lambda { |definition| yield definition if block_given? } diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index cd5d6f17d8..20579c6476 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -500,6 +500,10 @@ module ActiveRecord end end + def test_deprecate_valid_alter_table_type + assert_deprecated { @conn.valid_alter_table_type?(:string) } + end + private def assert_logged(logs) |