Skip to content

Commit

Permalink
Merge pull request #22388 from kamipo/set_field_encoding_is_only_need…
Browse files Browse the repository at this point in the history
…ed_for_mysql_adapter

`set_field_encoding` is only needed for `MysqlAdapter`
  • Loading branch information
sgrif committed Nov 23, 2015
2 parents 1e5c274 + d5ff01b commit 9d70526
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Expand Up @@ -588,10 +588,8 @@ def columns(table_name)#:nodoc:
sql = "SHOW FULL FIELDS FROM #{quote_table_name(table_name)}"
execute_and_free(sql, 'SCHEMA') do |result|
each_hash(result).map do |field|
field_name = set_field_encoding(field[:Field])
sql_type = field[:Type]
type_metadata = fetch_type_metadata(sql_type, field[:Extra])
new_column(field_name, field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation])
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
new_column(field[:Field], field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation])
end
end
end
Expand Down
Expand Up @@ -185,10 +185,6 @@ def configure_connection
def full_version
@full_version ||= @connection.server_info[:version]
end

def set_field_encoding field_name
field_name
end
end
end
end
Expand Up @@ -104,6 +104,11 @@ def each_hash(result) # :nodoc:
end
end

def new_column(field, default, sql_type_metadata = nil, null = true, default_function = nil, collation = nil) # :nodoc:
field = set_field_encoding(field)
super
end

def error_number(exception) # :nodoc:
exception.errno if exception.respond_to?(:errno)
end
Expand Down Expand Up @@ -463,7 +468,7 @@ def full_version
@full_version ||= @connection.server_info
end

def set_field_encoding field_name
def set_field_encoding(field_name)
field_name.force_encoding(client_encoding)
if internal_enc = Encoding.default_internal
field_name = field_name.encode!(internal_enc)
Expand Down

0 comments on commit 9d70526

Please sign in to comment.