aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-12-18 14:52:05 +1030
committerMatthew Draper <matthew@trebex.net>2015-12-18 14:52:05 +1030
commite0e918609fc394e4c36b73bb2b0a485612789d6f (patch)
tree9e7735a2405a8ed5835ec3ee549a9b8104f1274d /activerecord
parent093b3d6a967fe9e992a6de9527908e15345eb633 (diff)
parent835617b71d2e829c27dbd16a82f22c186c821a0f (diff)
downloadrails-e0e918609fc394e4c36b73bb2b0a485612789d6f.tar.gz
rails-e0e918609fc394e4c36b73bb2b0a485612789d6f.tar.bz2
rails-e0e918609fc394e4c36b73bb2b0a485612789d6f.zip
Merge pull request #20815 from byroot/do-not-include-column-limit-if-it-is-default
Do not include column limit in schema.rb if it matches the default
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md5
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb4
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb2
3 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index ecdb7e204a..2c5b670469 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Omit default limit values in dumped schema. It's tidier, and if the defaults
+ change in the future, we can address that via Migration API Versioning.
+
+ *Jean Boussier*
+
* Support passing the schema name as a prefix to table name in
`ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
be considered a full part of the index name, and only the schema in the
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 e252ddb4cf..797662d07c 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb
@@ -61,8 +61,8 @@ module ActiveRecord
end
def schema_limit(column)
- limit = column.limit || native_database_types[column.type][:limit]
- limit.inspect if limit
+ limit = column.limit
+ limit.inspect if limit && limit != native_database_types[column.type][:limit]
end
def schema_precision(column)
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index f98c9946e4..a7735a2c7e 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -118,7 +118,7 @@ class SchemaDumperTest < ActiveRecord::TestCase
assert_match %r{c_int_4.*}, output
assert_no_match %r{c_int_4.*limit:}, output
elsif current_adapter?(:Mysql2Adapter)
- assert_match %r{c_int_without_limit.*limit: 4}, output
+ assert_match %r{c_int_without_limit"$}, output
assert_match %r{c_int_1.*limit: 1}, output
assert_match %r{c_int_2.*limit: 2}, output