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.

Inserting id (primary column) from code.

See original GitHub issue

Issue type:

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

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ x ] postgres [ ] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[ x ] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

I have a table with id as PrimaryGeneratedColumn. In some scenario i need to give the id in code and dont want to use the autogenerated id. Even if i give id, it is being ignored.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:57
  • Comments:34 (10 by maintainers)

github_iconTop GitHub Comments

30reactions
krislefebercommented, May 26, 2018

What is your use case for this? If you don’t want it to auto-generate, then don’t use the PrimaryGeneratedColumn. If you manually set this id, the auto-increment could break on future entities that try to auto-generate an id with that value. I think it would be easier to have a separate field for the cases where you want to override the value.

21reactions
JClackettcommented, May 3, 2019

Also would really like this feature to use postgres!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to insert value into primary key column in SQL Server?
SET IDENTITY_INSERT Student ON; INSERT INTO Student VALUES('1','joedio','newyark',GETDATE()); SET IDENTITY_INSERT Student OFF;. If you wants ...
Read more >
Defining an Auto Increment Primary Key in SQL Server - Chartio
Learn how to define an auto increment primary key in SQL Server. This data tutorial will explain basic table creation and information around...
Read more >
SQL AUTO INCREMENT a Field - W3Schools
The SQL statement above would insert a new record into the "Persons" table. The "Personid" column would be assigned a unique value. The...
Read more >
MySQL Primary Key
A primary key is a column or a set of columns that uniquely identifies each row in the table. The primary key follows...
Read more >
MySQL Tutorial :: 7.9 Using AUTO_INCREMENT
When you insert any other value into an AUTO_INCREMENT column, the column is ... id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(30) NOT NULL,...
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