Sha256: dbb27a3ea696de438a3710a8ca7ba881863aee59a099f3fb465f512861bd2eb2

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

module ActiveRecord #:nodoc:
  module ConnectionAdapters #:nodoc:
    module OracleEnhancedDirty #:nodoc:

      module InstanceMethods #:nodoc:
        private

        def _field_changed?(attr, old_value)
          new_value = read_attribute(attr)
          raw_value = read_attribute_before_type_cast(attr)

          if self.class.columns_hash.include?(attr.to_s)
            column = column_for_attribute(attr)

            # Oracle stores empty string '' as NULL
            # therefore need to convert empty string value to nil if old value is nil
            if column.type == :string && column.null && old_value.nil?
              new_value = nil if new_value == ''
            end
            column.changed?(old_value, new_value, raw_value)
          else
            new_value != old_value
          end
        end

        def non_zero?(value)
          value !~ /\A0+(\.0+)?\z/
        end 
        
      end

    end
  end
end

if ActiveRecord::Base.method_defined?(:changed?)
  ActiveRecord::Base.class_eval do
    include ActiveRecord::ConnectionAdapters::OracleEnhancedDirty::InstanceMethods
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
activerecord-oracle_enhanced-adapter-1.6.9 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.8 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.7 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.6 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.5 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.4 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
pmacs-activerecord-oracle_enhanced-adapter-1.6.2.1 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.3 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.2 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.1 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.0 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb
activerecord-oracle_enhanced-adapter-1.6.0.beta1 lib/active_record/connection_adapters/oracle_enhanced/dirty.rb