diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-15 08:51:31 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-19 11:24:01 +0900 |
commit | 7ba2cd06a215f4f1f48e61957dda9ca4a880d0a4 (patch) | |
tree | 3010df7b12862c136fa54b6c2b0c3053fa001927 | |
parent | 949b1336266d3de25d5d84911c7a43f7da3121bf (diff) | |
download | rails-7ba2cd06a215f4f1f48e61957dda9ca4a880d0a4.tar.gz rails-7ba2cd06a215f4f1f48e61957dda9ca4a880d0a4.tar.bz2 rails-7ba2cd06a215f4f1f48e61957dda9ca4a880d0a4.zip |
Use `delegate` to call the methods to `@conn`
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb index bc8fa9b6cf..f754df93b6 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb @@ -18,6 +18,9 @@ module ActiveRecord "ADD #{accept(o)}" end + delegate :quote_column_name, :quote_table_name, :quote_default_expression, :type_to_sql, to: :@conn + private :quote_column_name, :quote_table_name, :quote_default_expression, :type_to_sql + private def visit_AlterTable(o) @@ -70,18 +73,6 @@ module ActiveRecord column_options end - def quote_column_name(name) - @conn.quote_column_name name - end - - def quote_table_name(name) - @conn.quote_table_name name - end - - def type_to_sql(type, limit, precision, scale) - @conn.type_to_sql type.to_sym, limit, precision, scale - end - def add_column_options!(sql, options) sql << " DEFAULT #{quote_default_expression(options[:default], options[:column])}" if options_include_default?(options) # must explicitly check for :null to allow change_column to work on migrations @@ -97,10 +88,6 @@ module ActiveRecord sql end - def quote_default_expression(value, column) - @conn.quote_default_expression(value, column) - end - def options_include_default?(options) options.include?(:default) && !(options[:null] == false && options[:default].nil?) end |