diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-07 09:32:01 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-07 09:32:01 +0900 |
commit | f4e2807a1a72873af5630fa19888ea5bd61aaafa (patch) | |
tree | 8582a200bfa8fd18b9e2307e3b93b009b7772cc9 /activerecord | |
parent | c9b514cd3e8fe7d74ae91ecd30db839132e7899c (diff) | |
download | rails-f4e2807a1a72873af5630fa19888ea5bd61aaafa.tar.gz rails-f4e2807a1a72873af5630fa19888ea5bd61aaafa.tar.bz2 rails-f4e2807a1a72873af5630fa19888ea5bd61aaafa.zip |
Use `information_schema` to extract `generation_expression` for MariaDB
Since MariaDB 10.2.5, `information_schema` supports Virtual Columns.
Fixes #29670.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/virtual_column_test.rb | 2 |
2 files changed, 2 insertions, 2 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 eff96e329f..a46d9f8cbb 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb @@ -53,7 +53,7 @@ module ActiveRecord end def extract_expression_for_virtual_column(column) - if mariadb? + if mariadb? && version < "10.2.5" create_table_info = create_table_info(column.table_name) if %r/#{quote_column_name(column.name)} #{Regexp.quote(column.sql_type)}(?: COLLATE \w+)? AS \((?<expression>.+?)\) #{column.extra}/ =~ create_table_info $~[:expression].inspect diff --git a/activerecord/test/cases/adapters/mysql2/virtual_column_test.rb b/activerecord/test/cases/adapters/mysql2/virtual_column_test.rb index 442a4fb7b5..1c5ef2aa41 100644 --- a/activerecord/test/cases/adapters/mysql2/virtual_column_test.rb +++ b/activerecord/test/cases/adapters/mysql2/virtual_column_test.rb @@ -52,7 +52,7 @@ if ActiveRecord::Base.connection.supports_virtual_columns? def test_schema_dumping output = dump_table_schema("virtual_columns") - assert_match(/t\.virtual\s+"upper_name",\s+type: :string,\s+as: "UPPER\(`name`\)"$/i, output) + assert_match(/t\.virtual\s+"upper_name",\s+type: :string,\s+as: "(?:UPPER|UCASE)\(`name`\)"$/i, output) assert_match(/t\.virtual\s+"name_length",\s+type: :integer,\s+as: "LENGTH\(`name`\)",\s+stored: true$/i, output) end end |