Sha256: eb1a603de40f91bc78ace3801d8e0b76a3ae2538b1f5fa43d382b285accc0ef8

Contents?: true

Size: 961 Bytes

Versions: 9

Compression:

Stored size: 961 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter
      def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
        # Extract the table from the insert sql. Yuck.
        _, table = extract_schema_and_table(sql.split(" ", 4)[2])

        pk ||= primary_key(table)

        if pk
          # CPK
          # select_value("#{sql} RETURNING #{quote_column_name(pk)}")
          select_value("#{sql} RETURNING #{quote_column_names(pk)}")
        else
          super
        end
      end
      alias :create :insert

      def sql_for_insert(sql, pk, id_value, sequence_name, binds)
        unless pk
          _, table = extract_schema_and_table(sql.split(" ", 4)[2])

          pk = primary_key(table)
        end

        # CPK
        # sql = "#{sql} RETURNING #{quote_column_name(pk)}" if pk
        sql = "#{sql} RETURNING #{quote_column_names(pk)}" if pk

        [sql, binds]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
composite_primary_keys-4.1.2 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.1.1 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta9 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta8 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta7 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta6 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta5 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
composite_primary_keys-4.0.0.beta4 lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb