Module: Sequel::Dataset::Replace

Included in:
MySQL::DatasetMethods
Defined in:
lib/sequel/adapters/utils/replace.rb

Constant Summary collapse

INSERT =
Dataset::INSERT
REPLACE =
'REPLACE'.freeze

Instance Method Summary collapse

Instance Method Details

#multi_replace(*values) ⇒ Object

Replace multiple rows in a single query.



21
22
23
# File 'lib/sequel/adapters/utils/replace.rb', line 21

def multi_replace(*values)
  clone(:replace=>true).multi_insert(*values)
end

#replace(*values) ⇒ Object

Execute a REPLACE statement on the database (deletes any duplicate rows before inserting).



11
12
13
# File 'lib/sequel/adapters/utils/replace.rb', line 11

def replace(*values)
  execute_insert(replace_sql(*values))
end

#replace_sql(*values) ⇒ Object

SQL statement for REPLACE



16
17
18
# File 'lib/sequel/adapters/utils/replace.rb', line 16

def replace_sql(*values)
  clone(:replace=>true).insert_sql(*values)
end

#supports_replace?Boolean

Databases using this module support REPLACE.

Returns:

  • (Boolean)


26
27
28
# File 'lib/sequel/adapters/utils/replace.rb', line 26

def supports_replace?
  true
end