diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-01-30 17:23:51 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-02-08 18:27:35 +0900 |
commit | 3bd83f016c4193f16613464f48020bdd6def32de (patch) | |
tree | ff6b76f7bd71f4c70de53252356bc8d825cacd63 /activerecord/lib | |
parent | 1492e83e49f74b1d874585000bad5368d9f09218 (diff) | |
download | rails-3bd83f016c4193f16613464f48020bdd6def32de.tar.gz rails-3bd83f016c4193f16613464f48020bdd6def32de.tar.bz2 rails-3bd83f016c4193f16613464f48020bdd6def32de.zip |
Add `auto_increment?` instead of `extra == 'auto_increment'`
Diffstat (limited to 'activerecord/lib')
-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"] |