bulk insert,Duplicate entry..primary key, createQueryBuilder
See original GitHub issueIssue 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:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hate when people solve problems and don’t share how
I resolve,thanks!