Method: Sequel::SQLite::DatasetMethods#insert_conflict
- Defined in:
- lib/sequel/adapters/shared/sqlite.rb
#insert_conflict(resolution = :ignore) ⇒ Object
Handle uniqueness violations when inserting, by using a specified resolution algorithm. With no options, uses INSERT OR REPLACE. SQLite supports the following conflict resolution algoriths: ROLLBACK, ABORT, FAIL, IGNORE and REPLACE.
Examples:
DB[:table].insert_conflict.insert(:a=>1, :b=>2)
# INSERT OR IGNORE INTO TABLE (a, b) VALUES (1, 2)
DB[:table].insert_conflict(:replace).insert(:a=>1, :b=>2)
# INSERT OR REPLACE INTO TABLE (a, b) VALUES (1, 2)
623 624 625 |
# File 'lib/sequel/adapters/shared/sqlite.rb', line 623 def insert_conflict(resolution = :ignore) clone(:insert_conflict => resolution) end |