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.

InsertResult return the same primary key

See original GitHub issue

Issue type:

[ x] question [ x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[x ] sqlite

TypeORM version:

[x ] @next

@Entity()
export default class Marker extends BaseEntity {
  @PrimaryGeneratedColumn() id = undefined

  @Column('varchar') type = undefined
  @Column('varchar', {
    nullable: true
  })
  desc = undefined
  @Column('double') long = undefined
  @Column('double') lat = undefined

  @Column('varchar', {
    nullable: true
  })
  data = undefined

  @CreateDateColumn() createTime = undefined
  @UpdateDateColumn() updateTime = undefined

  @ManyToOne(type => ProjectPanorama,{
    onDelete: 'CASCADE'
  })
  projectPanorama
}

console.log(project.panoramas.find(projectP => projectP.id === p.id).markers)

const newMarkers = (await connection
        .createQueryBuilder()
        .insert()
        .into(Marker)
        .values(project.panoramas.find(projectP => projectP.id === p.id).markers)
        .printSql()
        .execute()).identifiers 
console.log(newMarkers)

first log

 [    { 
          type: 'jump',
          desc: null,
          long: 2,
          lat: 1.5,
          data: null,
          createTime: '2018-05-13T08:41:04.000Z',
          updateTime: '2018-05-13T08:41:04.000Z' },
        { desc: 'my desc', type: 'jump', long: 1, lat: 1 } 
]

second log

 [ { id: 92 }, { id: 92 } ]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:20
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
olosegrescommented, Aug 5, 2020

I spent a lot of hours trying to find cause of my product’s much higher level bug, but the root of the problems, as it turned out, is this bug 😦

4reactions
dmluxcommented, Sep 17, 2018

Same happens when using mysql databases. Would be cool if “identifiers” and “generatedMaps” contain the correct ids for all inserted objects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning ID of inserted query in TypeORM and MySQL
I,m new to TypeORM and I have problem that I'm trying to solve. I'm wondering how to retrieve ID after INSERT query. I...
Read more >
InsertResult in sea_orm - Rust - Docs.rs
pub struct InsertResult<A>where ... The id performed when AUTOINCREMENT was performed on the PrimaryKey ... impl<T> Same<T> for T.
Read more >
InsertResult | kysely
Class InsertResult. The result of an insert query. If the table has an auto incrementing primary key insertId will hold the generated id...
Read more >
INSERT | CQL for Cassandra 3.x - DataStax Documentation
Inserts an entire row or upserts data into an existing row, using the full primary key. Requires a value for each component of...
Read more >
upper/db - Go Packages
New(`upper: collection %q has no primary keys`) ErrWarnSlowQuery ... type InsertResult interface { // ID returns the ID of the newly ...
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