diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 799b302a94..1b6ccdc7fc 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -253,9 +253,7 @@ module ActiveRecord # Requests a maximum column length (<tt>:string</tt>, <tt>:text</tt>, # <tt>:binary</tt> or <tt>:integer</tt> columns only) # * <tt>:default</tt>: - # The column's default value. You cannot explicitely set the default - # value to +NULL+. Simply leave off this option if you want a +NULL+ - # default value. + # The column's default value. Use nil for NULL. # * <tt>:null</tt>: # Allows or disallows +NULL+ values in the column. This option could # have been named <tt>:null_allowed</tt>. @@ -271,11 +269,11 @@ module ActiveRecord # <tt>:precision</tt>. # * MySQL: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..30]. # Default is (10,0). - # * PostGres?: <tt>:precision</tt> [1..infinity], + # * PostgreSQL: <tt>:precision</tt> [1..infinity], # <tt>:scale</tt> [0..infinity]. No default. - # * Sqlite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used. + # * SQLite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used. # Internal storage as strings. No default. - # * Sqlite3: No restrictions on <tt>:precision</tt> and <tt>:scale</tt>, + # * SQLite3: No restrictions on <tt>:precision</tt> and <tt>:scale</tt>, # but the maximum supported <tt>:precision</tt> is 16. No default. # * Oracle: <tt>:precision</tt> [1..38], <tt>:scale</tt> [-84..127]. # Default is (38,0). diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 8891c10c7c..edb3042afc 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -273,10 +273,10 @@ module ActiveRecord column_type_sql << "(#{limit})" if limit column_type_sql end - end - + end + def add_column_options!(sql, options) #:nodoc: - sql << " DEFAULT #{quote(options[:default], options[:column])}" unless options[:default].nil? + sql << " DEFAULT #{quote(options[:default], options[:column])}" if options_include_default?(options) sql << " NOT NULL" if options[:null] == false end @@ -293,6 +293,11 @@ module ActiveRecord def add_order_by_for_association_limiting!(sql, options) sql << "ORDER BY #{options[:order]}" end + + protected + def options_include_default?(options) + options.include?(:default) && !(options[:null] == false && options[:default].nil?) + end end end end |