Class: InsertSelect::Adapters::PostgresqlAdapter

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/insert_select/adapters/postgresql_adapter.rb

Instance Attribute Summary

Attributes inherited from BaseAdapter

#connection, #table_name

Instance Method Summary collapse

Constructor Details

#initialize(table_name, connection) ⇒ PostgresqlAdapter

Returns a new instance of PostgresqlAdapter.



4
5
6
7
# File 'lib/insert_select/adapters/postgresql_adapter.rb', line 4

def initialize(table_name, connection)
  @table_name = table_name
  @connection = connection
end

Instance Method Details

#build_sql(builder) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/insert_select/adapters/postgresql_adapter.rb', line 9

def build_sql(builder)
  stmt = super

  stmt << " ON CONFLICT DO NOTHING" if builder.on_duplicate == :skip
  stmt << " RETURNING #{builder.returning}" if builder.returning?

  stmt
end