mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge branch 'master' of git://github.com/rails/rails
Conflicts: activerecord/CHANGELOG.md
This commit is contained in:
commit
dc0d303127
4 changed files with 24 additions and 6 deletions
|
@ -39,6 +39,12 @@
|
|||
|
||||
*Jenn Cooper*
|
||||
|
||||
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
||||
|
||||
Fixes #15931.
|
||||
|
||||
*Jeff Browning*
|
||||
|
||||
* Calling `#empty?` on a `has_many` association would use the value from the
|
||||
counter cache if one exists.
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def rename_index(table_name, old_name, new_name)
|
||||
if (version[0] == 5 && version[1] >= 7) || version[0] >= 6
|
||||
if supports_rename_index?
|
||||
execute "ALTER TABLE #{quote_table_name(table_name)} RENAME INDEX #{quote_table_name(old_name)} TO #{quote_table_name(new_name)}"
|
||||
else
|
||||
super
|
||||
|
@ -774,10 +774,22 @@ module ActiveRecord
|
|||
|
||||
private
|
||||
|
||||
def version
|
||||
@version ||= full_version.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
|
||||
end
|
||||
|
||||
def mariadb?
|
||||
full_version =~ /mariadb/i
|
||||
end
|
||||
|
||||
def supports_views?
|
||||
version[0] >= 5
|
||||
end
|
||||
|
||||
def supports_rename_index?
|
||||
mariadb? ? false : (version[0] == 5 && version[1] >= 7) || version[0] >= 6
|
||||
end
|
||||
|
||||
def configure_connection
|
||||
variables = @config.fetch(:variables, {}).stringify_keys
|
||||
|
||||
|
|
|
@ -269,8 +269,8 @@ module ActiveRecord
|
|||
super
|
||||
end
|
||||
|
||||
def version
|
||||
@version ||= @connection.info[:version].scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
|
||||
def full_version
|
||||
@full_version ||= @connection.info[:version]
|
||||
end
|
||||
|
||||
def set_field_encoding field_name
|
||||
|
|
|
@ -470,9 +470,9 @@ module ActiveRecord
|
|||
rows
|
||||
end
|
||||
|
||||
# Returns the version of the connected MySQL server.
|
||||
def version
|
||||
@version ||= @connection.server_info.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
|
||||
# Returns the full version of the connected MySQL server.
|
||||
def full_version
|
||||
@full_version ||= @connection.server_info
|
||||
end
|
||||
|
||||
def set_field_encoding field_name
|
||||
|
|
Loading…
Reference in a new issue