Inserting id (primary column) from code.
See original GitHub issueIssue 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:
- Created 5 years ago
- Reactions:57
- Comments:34 (10 by maintainers)
Top 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 >
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 Free
Top 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
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.
Also would really like this feature to use postgres!