Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

396
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda