Sha256: 95015d567ef3ad6fc4befcab640238121be0a76a70b5443c744be93f0b24a3d5

Contents?: true

Size: 1 KB

Versions: 34

Compression:

Stored size: 1 KB

Contents

module ArJdbc
  module QuotedPrimaryKeyExtension
    def self.extended(base)
      #       Rails 3 method           Rails 2 method
      meth = [:arel_attributes_values, :attributes_with_quotes].detect do |m|
        base.private_instance_methods.include?(m.to_s)
      end
      pk_hash_key = "self.class.primary_key"
      pk_hash_value = '"?"'
      if meth == :arel_attributes_values
        pk_hash_key = "self.class.arel_table[#{pk_hash_key}]"
        pk_hash_value = "Arel::SqlLiteral.new(#{pk_hash_value})"
      end
      if meth
        base.module_eval <<-PK, __FILE__, __LINE__
          alias :#{meth}_pre_pk :#{meth}
          def #{meth}(include_primary_key = true, *args) #:nodoc:
            aq = #{meth}_pre_pk(include_primary_key, *args)
            if connection.is_a?(ArJdbc::Oracle) || connection.is_a?(ArJdbc::Mimer)
              aq[#{pk_hash_key}] = #{pk_hash_value} if include_primary_key && aq[#{pk_hash_key}].nil?
            end
            aq
          end
        PK
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 8 rubygems

Version Path
activerecord-jdbc-adapter-1.2.9.1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.0.beta2 lib/arjdbc/jdbc/quoted_primary_key.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.0.beta1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.9 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.8 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.5 lib/arjdbc/jdbc/quoted_primary_key.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arjdbc/jdbc/quoted_primary_key.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arjdbc/jdbc/quoted_primary_key.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arjdbc/jdbc/quoted_primary_key.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arjdbc/jdbc/quoted_primary_key.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arjdbc/jdbc/quoted_primary_key.rb
intentmedia-activerecord-jdbc-adapter-1.1.1.1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.2 lib/arjdbc/jdbc/quoted_primary_key.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.1 lib/arjdbc/jdbc/quoted_primary_key.rb
c3-activerecord-jdbc-adapter-1.1.3.1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.2.0 lib/arjdbc/jdbc/quoted_primary_key.rb