inheritance - change primary key options
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
class Base {
@PrimaryGeneratedColumn()
id:number;
}
@Entity()
class Demo extends Base {
@PrimaryColumn({
generated:false
})
id:number;
}
It created a table demo
with primary key id
auto incremented. generated:false
is not working.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Inherited Class With Primary Key of Base Class and Another ...
I have a base class with id of type Int. I have a class B inherited of base class. Class B has an...
Read more >Documentation: 15: 5.10. Inheritance - PostgreSQL
PostgreSQL implements table inheritance, which can be a useful tool for database designers. ... primary key, and foreign key constraints) are not inherited....
Read more >Why is the type of inheritance required to be primary key (PK ...
Apparently, the answer to this question is pretty trivial: relationship types generally don't have their own primary key attributes.
Read more >sql server - Primary keys due to inheritance
I am trying to design a database for postgrad office and we have a parent class "User" that has a username as a...
Read more >Join inheritance type and composite primary keys — oracle-tech
Child]. When specifying @PrimaryKeyJoinColumns for an entity that has a composite primary key, a @PrimaryKeyJoinColumn must be specified for ...
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 FreeTop 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
Top GitHub Comments
@vlapo No, it’s not the same.
My propose
Base
class is not going to sharing tables. It is the template to use in every tables.number
, but maybeinteger
orfloat
) it is still reasonable. (repeat it is not table inheritance. there is no@TableInheritance
)Real scenario
I have multiple tables all with a primary
id
using the same typeint
. Most of those areauto increment
. But there is one table usingone-to-one
relation with shared primary/foreign keys. So the child table’s (which has foreign key) primary key must be mandatory set the same value from the main table. So thegenerated
need set tofalse
.I know it is not a same. I just want link this issue with #2865, in case someone will implement enhancement of inheritance (basically both problems are with inheritance and primary columns).
I understand your problem but it is not implemented. It is not possible define superclass with primary generated column, extends and disable auto generation in in subclass 😃