Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Mulitiple row insert in Sequel skip if unique constrain occurs Ruby sequel

I know Dataset#multi_insert and Dataset#insert. does multi insert but is there an option available that can skip that particular insert when unique constrain check get activated

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use insert_conflict method.

"Handle uniqueness violations when inserting, by updating the conflicting row, using ON CONFLICT. With no options, uses ON CONFLICT DO NOTHING."

DB[:table].insert_conflict.insert(a: 1, b: 2)
# INSERT INTO TABLE (a, b) VALUES (1, 2)
# ON CONFLICT DO NOTHING

It also works with multi_insert

DB[:table].insert_conflict.multi_insert([{a: 1, b: 2}, {a: 3, b: 4}])
# INSERT INTO TABLE (a, b) VALUES (1, 2), (3, 4)
# ON CONFLICT DO NOTHING
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!