diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2015-02-08 13:07:53 +0000 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2015-02-08 13:07:53 +0000 |
commit | b1e6794238d7eac958cf146134220f6757fe0789 (patch) | |
tree | 611116ca71f1467d5139894d776bee4b77b9fa21 /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | |
parent | b7e592bd3b610616b038faa632c09ba194d452a4 (diff) | |
parent | 3bd83f016c4193f16613464f48020bdd6def32de (diff) | |
download | rails-b1e6794238d7eac958cf146134220f6757fe0789.tar.gz rails-b1e6794238d7eac958cf146134220f6757fe0789.tar.bz2 rails-b1e6794238d7eac958cf146134220f6757fe0789.zip |
Merge pull request #18848 from kamipo/add_auto_increment_method
Add `auto_increment?` instead of `extra == 'auto_increment'`
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 61bac6741f..1ce5f5ae58 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -63,7 +63,7 @@ module ActiveRecord def column_spec_for_primary_key(column) spec = {} - if column.extra == 'auto_increment' + if column.auto_increment? return unless column.limit == 8 spec[:id] = ':bigint' else @@ -103,6 +103,10 @@ module ActiveRecord collation && !collation.match(/_ci$/) end + def auto_increment? + extra == 'auto_increment' + end + private # MySQL misreports NOT NULL column default when none is given. @@ -808,7 +812,7 @@ module ActiveRecord options = { default: column.default, null: column.null, - auto_increment: column.extra == "auto_increment" + auto_increment: column.auto_increment? } current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'", 'SCHEMA')["Type"] |