diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-06 22:16:19 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-02-06 22:16:19 -0700 |
commit | 968e66b5df92e5ae88c033dc552e17b4c736874b (patch) | |
tree | d3ff117eef279026e544fc12bc81aaf25fb4c411 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | e0e20d62a75d2c05c7f68e0f316effd5c2f5c26f (diff) | |
parent | 29c70abc58357e7b0f6b05e9ca89ba7a95617ed5 (diff) | |
download | rails-968e66b5df92e5ae88c033dc552e17b4c736874b.tar.gz rails-968e66b5df92e5ae88c033dc552e17b4c736874b.tar.bz2 rails-968e66b5df92e5ae88c033dc552e17b4c736874b.zip |
Merge pull request #27389 from kamipo/fix_mysql_pk_dumping_correctly
Restore the behaviour of the compatibility layer for integer-like PKs
* kamipo/fix_mysql_pk_dumping_correctly:
Restore custom primary key tests lost at #26266
Restore the behaviour of the compatibility layer for integer-like PKs
Correctly dump integer-like primary key with default nil
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb index f0f4b5e565..34036d8a1d 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb @@ -14,6 +14,8 @@ module ActiveRecord return {} if default_primary_key?(column) spec = { id: schema_type(column).inspect } spec.merge!(prepare_column_options(column).except!(:null)) + spec[:default] ||= "nil" if explicit_primary_key_default?(column) + spec end # This can be overridden on an Adapter level basis to support other @@ -60,6 +62,10 @@ module ActiveRecord schema_type(column) == :bigint end + def explicit_primary_key_default?(column) + false + end + def schema_type_with_virtual(column) if supports_virtual_columns? && column.virtual? :virtual |