Sha256: d30793e0c3229e1af647abacd69aac87a7df29ea3748b337d68328835b6f033a

Contents?: true

Size: 1021 Bytes

Versions: 30

Compression:

Stored size: 1021 Bytes

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__ + 1
          alias :#{meth}_pre_pk :#{meth}
          def #{meth}(include_primary_key = true, *args)
            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

30 entries across 30 versions & 2 rubygems

Version Path
activerecord-jdbc-adapter-1.3.25 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-51.0 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.24 lib/arjdbc/jdbc/quoted_primary_key.rb
neo-activerecord-jdbc-adapter-5.0.pre2 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.23 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.22 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-5.0.pre1 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.21 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.20 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.19 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.18 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.17 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.16 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.15 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.14 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.13 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.12 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.11 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.10 lib/arjdbc/jdbc/quoted_primary_key.rb
activerecord-jdbc-adapter-1.3.9 lib/arjdbc/jdbc/quoted_primary_key.rb