Class: BulkInsert::StatementAdapters::PostgreSQLAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- BulkInsert::StatementAdapters::PostgreSQLAdapter
show all
- Defined in:
- lib/bulk_insert/statement_adapters/postgresql_adapter.rb
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#initialize
Instance Method Details
#insert_ignore_statement ⇒ Object
6
7
8
|
# File 'lib/bulk_insert/statement_adapters/postgresql_adapter.rb', line 6
def insert_ignore_statement
''
end
|
#on_conflict_statement(columns, ignore, update_duplicates) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/bulk_insert/statement_adapters/postgresql_adapter.rb', line 10
def on_conflict_statement(columns, ignore, update_duplicates)
if ignore
' ON CONFLICT DO NOTHING'
elsif update_duplicates
update_values = columns.map do |column|
"#{column.name}=EXCLUDED.#{column.name}"
end.join(', ')
' ON CONFLICT(' + update_duplicates.join(', ') + ') DO UPDATE SET ' + update_values
else
''
end
end
|
#primary_key_return_statement(primary_key) ⇒ Object
23
24
25
|
# File 'lib/bulk_insert/statement_adapters/postgresql_adapter.rb', line 23
def primary_key_return_statement(primary_key)
" RETURNING #{primary_key}"
end
|