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.



19
20
21
# File 'lib/sequel/adapters/utils/replace.rb', line 19

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).



9
10
11
# File 'lib/sequel/adapters/utils/replace.rb', line 9

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

#replace_sql(*values) ⇒ Object

SQL statement for REPLACE



14
15
16
# File 'lib/sequel/adapters/utils/replace.rb', line 14

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

#supports_replace?Boolean

Databases using this module support REPLACE.

Returns:

  • (Boolean)


24
25
26
# File 'lib/sequel/adapters/utils/replace.rb', line 24

def supports_replace?
  true
end