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

394
Views
Typeorm bigint type key insertion (NestJs)

i use nestjs/typeorm version 8, mysql version 8.

I've tried to insert bigint type data, which is Auto Generated primary key.

Insertion was perfectly fine but the InsertResult has incorrect key value.

looks like Typeorm attached a '0' end of the id string.

InsertResult {
     identifiers: [ { id: '900719950050204930' } ],
     generatedMaps: [ { id: '900719950050204930' } ],
     raw: ResultSetHeader {
         fieldCount: 0,
         affectedRows: 1,
         insertId: '90071995005020493',    
         info: '',
         serverStatus: 2,
         warningStatus: 0
         }
     }

the correct id is '90071995005020493'

but identifiers and generatedMaps property has '900719950050204930'

It happend when I used 'save()' method too.

the output entity get incorrect key value.

why it happend? how can i fix it...

it's my entity

export class MyEntity{
  @PrimaryGeneratedColumn({
    name: 'id',
    type: 'bigint',
    comment: 'id',
  })
  id: string;

  @Column('varchar', {
    name: 'header',
    default: '',
    comment: 'header',
  })
  header: string;

  @Column('varchar', {
    name: 'title',
    default: '',
    comment: 'title',
  })
  title: string;
}

and insert() method call

const newMyEntity = this.myEntityRepository.create();
newMyEntity.header  = '';
newMyEntity.title = '';

const insertResult = await this.myEntityRepository.insert(newMyEntity);
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!