class MultiInsert::Query::OnConflict

A conflict close inside a query.

You never need to instanciate it yourself. Instead, use `Query#on_conflict`.

Public Class Methods

new(query, column) click to toggle source

Create an ON CONFLICT clause

@param query [Query] the query. @param column [String | Symbol | nil] the column to watch for conflicts.

# File lib/multi_insert/query.rb, line 18
def initialize(query, column)
  @query = query
  @column = column
end

Public Instance Methods

do_nothing() click to toggle source

Ignore conflicting rows.

@return [Query] the original query.

# File lib/multi_insert/query.rb, line 26
def do_nothing
  @query.on_conflict_sql(::MultiInsert::QueryBuilder.on_conflict_do_nothing(@column))
end
do_update(values) click to toggle source

Update the conflicting rows according to user-supplied rules.

The rules can be:

  • A single symbol or string denoting a column name. In this case, the matching column will be updated.

  • An array of strings or symbols. In this case, the matching columns will be updated.

  • An hash of values (Integers or Strings) or the symbol `:excluded`. The matching columns will be updated

to the supplied values, except when the value is `:excluded`. In that case, the matching columns will be set to the value to be inserted.

@param values [String | Symbol | Array<String | Symbol> | Hash<String | Symbol => String | Number | Boolean>] The user specified rules. @return [Query] The original query.

# File lib/multi_insert/query.rb, line 41
def do_update(values)
  @query.on_conflict_sql(::MultiInsert::QueryBuilder.on_conflict_do_update(@column, values, @query.opts))
end