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

329
Views
How to solve in Knex.js ON CONFLICT DO UPDATE command cannot affect row a second time

I had built a query in Knex.js to insert records to the DB

upsert(input) {
    if (isEmpty(input)) return Promise.resolve(0);

    return this.tx(tableName)
      .insert(input.map(prepareInput))
      .onConflict([columns.candidateId, columns.startAt])
      .merge()
      .returning()
      .then(({ rowCount }) => rowCount);
  }

But I'm getting this error

ON CONFLICT DO UPDATE command cannot affect row a second time

I need to insert data and merge it with the existing one and not sure how should I edit this query to avoid the error

about 4 years ago · Juan Pablo Isaza
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!