diff options
Diffstat (limited to 'activerecord/lib')
3 files changed, 11 insertions, 40 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 659e512ce2..dc68b01386 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1296,6 +1296,12 @@ module ActiveRecord # If using with the <tt>:through</tt> option, the association on the join model must be # a #belongs_to, and the records which get deleted are the join records, rather than # the associated records. + # + # If using <tt>dependent: :destroy</tt> on a scoped association, only the scoped objects are destroyed. + # For example, if a Post model defines + # <tt>has_many :comments, -> { where published: true }, dependent: :destroy</tt> and <tt>destroy</tt> is + # called on a post, only published comments are destroyed. This means that any unpublished comments in the + # database would still contain a foreign key pointing to the now deleted post. # [:counter_cache] # This option can be used to configure a custom named <tt>:counter_cache.</tt> You only need this option, # when you customized the name of your <tt>:counter_cache</tt> on the #belongs_to association. diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb index a6b5a89ec0..74bff229ea 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb @@ -7,7 +7,7 @@ module ActiveRecord :bit end - def cast(value) + def cast_value(value) if ::String === value case value when /^0x/i @@ -16,7 +16,7 @@ module ActiveRecord value # Bit-string notation end else - value + value.to_s end end diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index be74922453..b65d5b56f1 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -16,22 +16,6 @@ module ActiveRecord cattr_accessor :ignore_tables @@ignore_tables = [] - ## - # :singleton-method: - # Define whether column arguments are lined up in dump. - # Acceptable values are true or false. - # This setting is only used if ActiveRecord::Base.schema_format == :ruby - cattr_accessor :standardized_argument_widths - @@standardized_argument_widths = true - - ## - # :singleton-method: - # Define whether columns types are lined up in dump. - # Acceptable values are true or false. - # This setting is only used if ActiveRecord::Base.schema_format == :ruby - cattr_accessor :standardized_type_widths - @@standardized_type_widths = true - class << self def dump(connection=ActiveRecord::Base.connection, stream=STDOUT, config = ActiveRecord::Base) new(connection, generate_options(config)).dump(stream) @@ -162,32 +146,13 @@ HEADER keys = @connection.migration_keys # figure out the lengths for each column based on above keys - lengths = if standardized_argument_widths - keys.map { |key| - column_specs.map { |spec| - spec[key] ? spec[key].length + 2 : 0 - }.max - } - else - [0] * keys.length - end + lengths = [0] * keys.length # the string we're going to sprintf our values against, with standardized column widths - format_string = if standardized_argument_widths - lengths.map { |len| "%-#{len}s" } - else - ["%s"] * keys.length - end + format_string = ["%s"] * keys.length # add column type definition to our format string - if standardized_type_widths - # find the max length for the 'type' column, which is special - type_length = column_specs.map { |column| column[:type].length }.max - - format_string.unshift " t.%-#{type_length}s " - else - format_string.unshift " t.%s " - end + format_string.unshift " t.%s " format_string *= "" |