question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bulk insert,Duplicate entry..primary key, createQueryBuilder

See original GitHub issue

Issue type:

[ ] question

Database system/driver:

[ ] mysql / mariadb

TypeORM version:

[ ] latest

Steps to reproduce or a small repository showing the problem:

import {getConnection} from “typeorm”;

await getConnection() .createQueryBuilder() .insert() .into(User) .values([ { id: 1, firstName: “Timber”, lastName: “Saw” }, { id: 2, firstName: “Phantom”, lastName: “Lancer” } ]) .execute();

tips: id is primary key

question: If id exists without inserting, how to write?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

115reactions
darkyeloxcommented, Oct 19, 2018

I hate when people solve problems and don’t share how

68reactions
JingMocommented, May 2, 2018

I resolve,thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeORM Throwing Duplication Error on Bulk saving instead ...
I have ended up solving this by RAW SQL query using the following return this.articleRepository.query( "INSERT IGNORE INTO articles ( title, ...
Read more >
How to Avoid Inserting Duplicate Records in SQL INSERT ...
This article discusses inserting records from another table or tables using an INSERT INTO SELECT statement without duplicate key errors.
Read more >
Duplicate primary key in bulk insert after truncate in SQL ...
Try bulk inserting into a new table, without the PK constraint, and then check the table for duplicates (probably easier than writing some...
Read more >
[Solved]-MySQL INSERT IGNORE or ON DUPLICATE KEY ...
INSERT IGNORE or ON DUPLICATE KEY works only when a unique key is duplicated. You need to add a UNIQUE index on both...
Read more >
Eliminating Duplicate Rows using SELECT DISTINCT in ...
INSERT INTO wp.temp_table. SELECT DISTINCT * FROM wp.amalgamated_actors;. The SELECT DISTINCT clause is key to removing duplicate rows.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found