Permalink
Browse files

Backport parts of #29876 to fix MariaDB tests

1) Currently `version` method always returns `5.5.5` because the
`full_version` is `5.5.5-10.x.y-MariaDB...` since MariaDB 10.x.
It should be ignored if the prefix is `5.5.5-`.

2) Use `information_schema` to extract `generation_expression` for MariaDB
Since MariaDB 10.2.5, `information_schema` supports Virtual Columns.

Couldn't backport #29876 cleanly so had to manually backport.

[Eileen M. Uchitelle & Ryuta Kamizono]
  • Loading branch information...
eileencodes committed Dec 11, 2017
1 parent 55bcd2f commit 17af04bc95def1e471fc8ac3469f50de0e88ff5c
Showing with 8 additions and 4 deletions.
  1. +8 −4 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -68,7 +68,7 @@ def initialize(connection, logger, connection_options, config)
@statements = StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))
if version < '5.0.0'
raise "Your version of MySQL (#{full_version.match(/^\d+\.\d+\.\d+/)[0]}) is too old. Active Record supports MySQL >= 5.0."
raise "Your version of MySQL (#{version_string}) is too old. Active Record supports MySQL >= 5.0."
end
end
@@ -81,7 +81,7 @@ def internal_string_options_for_primary_key # :nodoc:
end
def version #:nodoc:
@version ||= Version.new(full_version.match(/^\d+\.\d+\.\d+/)[0])
@version ||= Version.new(version_string)
end
def mariadb? # :nodoc:
@@ -399,8 +399,8 @@ def columns(table_name) # :nodoc:
table_name = table_name.to_s
column_definitions(table_name).map do |field|
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
if type_metadata.type == :datetime && field[:Default] == "CURRENT_TIMESTAMP"
default, default_function = nil, field[:Default]
if type_metadata.type == :datetime && field[:Default] =~ /\ACURRENT_TIMESTAMP(?:\(\))?\z/i
default, default_function = nil, "CURRENT_TIMESTAMP"
else
default, default_function = field[:Default], nil
end
@@ -940,6 +940,10 @@ def binary_to_sql(limit) # :nodoc:
end
end
def version_string
full_version.match(/^(?:5\.5\.5-)?(\d+\.\d+\.\d+)/)[1]
end
class MysqlJson < Type::Internal::AbstractJson # :nodoc:
def changed_in_place?(raw_old_value, new_value)
# Normalization is required because MySQL JSON data format includes

0 comments on commit 17af04b

Please sign in to comment.