From f185e0ebc9cc18c596eb9cab1a9cd99e26a20500 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 8 Apr 2019 18:57:05 +0900 Subject: Except `table_name` from column objects The `table_name` was added at #23677 to detect whether serial column or not correctly. We can do that detection before initialize column object, it makes column object size smaller, and it probably helps column object de-duplication. --- .../lib/active_record/connection_adapters/mysql/schema_dumper.rb | 6 +++--- .../active_record/connection_adapters/mysql/schema_statements.rb | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/mysql') diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb index a37557361a..234fb25fdf 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb @@ -55,7 +55,7 @@ module ActiveRecord end def schema_collation(column) - if column.collation && table_name = column.table_name + if column.collation @table_collation_cache ||= {} @table_collation_cache[table_name] ||= @connection.exec_query("SHOW TABLE STATUS LIKE #{@connection.quote(table_name)}", "SCHEMA").first["Collation"] @@ -65,13 +65,13 @@ module ActiveRecord def extract_expression_for_virtual_column(column) if @connection.mariadb? && @connection.database_version < "10.2.5" - create_table_info = @connection.send(:create_table_info, column.table_name) + create_table_info = @connection.send(:create_table_info, table_name) column_name = @connection.quote_column_name(column.name) if %r/#{column_name} #{Regexp.quote(column.sql_type)}(?: COLLATE \w+)? AS \((?.+?)\) #{column.extra}/ =~ create_table_info $~[:expression].inspect end else - scope = @connection.send(:quoted_scope, column.table_name) + scope = @connection.send(:quoted_scope, table_name) column_name = @connection.quote(column.name) sql = "SELECT generation_expression FROM information_schema.columns" \ " WHERE table_schema = #{scope[:schema]}" \ diff --git a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb index ad3a8d1fd9..a24c432893 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb @@ -174,9 +174,8 @@ module ActiveRecord default, type_metadata, field[:Null] == "YES", - table_name, default_function, - field[:Collation], + collation: field[:Collation], comment: field[:Comment].presence ) end -- cgit v1.2.3