diff options
author | Ali Ibrahim <aibrahim2k2@gmail.com> | 2019-03-29 11:18:48 -0400 |
---|---|---|
committer | Ali Ibrahim <aibrahim2k2@gmail.com> | 2019-04-03 11:10:14 -0400 |
commit | 1c6e508ade793b5f2676e9218ab2f4cc9474f9ce (patch) | |
tree | d890ba17fd2abdb8fee40b3e4dd04259a79613cc /activerecord/lib/active_record/connection_adapters/mysql | |
parent | beb0bc9907a31d0cbd2ca68c79c57a9e375761e8 (diff) | |
download | rails-1c6e508ade793b5f2676e9218ab2f4cc9474f9ce.tar.gz rails-1c6e508ade793b5f2676e9218ab2f4cc9474f9ce.tar.bz2 rails-1c6e508ade793b5f2676e9218ab2f4cc9474f9ce.zip |
Cache database version in schema cache
* The database version will get cached in the schema cache file during the
schema cache dump. When the database version check happens, the version will
be pulled from the schema cache and thus avoid querying the database for
the version.
* If the schema cache file doesn't exist, we'll query the database for the
version and cache it on the schema cache object.
* To facilitate this change, all connection adapters now implement
#get_database_version and #database_version. #database_version returns the
value from the schema cache.
* To take advantage of the cached database version, the database version check
will now happen after the schema cache is set on the connection in the
connection pool.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb | 4 |
2 files changed, 3 insertions, 3 deletions
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 57518b02fa..a37557361a 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb @@ -64,7 +64,7 @@ module ActiveRecord end def extract_expression_for_virtual_column(column) - if @connection.mariadb? && @connection.version < "10.2.5" + if @connection.mariadb? && @connection.database_version < "10.2.5" create_table_info = @connection.send(:create_table_info, column.table_name) column_name = @connection.quote_column_name(column.name) if %r/#{column_name} #{Regexp.quote(column.sql_type)}(?: COLLATE \w+)? AS \((?<expression>.+?)\) #{column.extra}/ =~ create_table_info 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 4018f0815c..a1f90a0642 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb @@ -126,9 +126,9 @@ module ActiveRecord def row_format_dynamic_by_default? if mariadb? - version >= "10.2.2" + database_version >= "10.2.2" else - version >= "5.7.9" + database_version >= "5.7.9" end end |