Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Support for inheritance feature in Postgres #304

Open
acisser opened this issue Oct 22, 2020 · 4 comments
Open

Support for inheritance feature in Postgres #304

acisser opened this issue Oct 22, 2020 · 4 comments
Labels
enhancement new feature or bug with easy workaround

Comments

@acisser
Copy link

acisser commented Oct 22, 2020

The model generation for Postgres engine is not working when data model contains inheritance Postgres feature.

The cli is raising the following error.

Table Person has no PK
Error occurred in typeorm-model-generator.

@Kononnable
Copy link
Owner

As I understand with this feature same data is accessible(and modifiable) in multiple tables. Unless ORM support such feature directly it's not wise to use them together(at least in any automated way). You can end up with weird ORM errors or in worst case in data corruption.
Why? ORM often 'caches' some values so it would work faster(or detect model changes), if data is linked on the db side this may lead to unexpected consequences like data corruption.
As far as I know typeorm doesn't support inheritance on database level(only on typescript model level), so support for such tables will have to way until typeorm can understand that kind of relation.

@Kononnable Kononnable added enhancement new feature or bug with easy workaround typeorm implementation needed labels Oct 27, 2020
@acisser
Copy link
Author

acisser commented Nov 7, 2020

The inheritance feature for Postgres is just for modeling purposes since it's actually not using a common table for sharing those common columns. It will append that list of columns declared in the base table declaration to each of the actual physical tables inheriting from it.

After checking this issue twice. I realized that even the console raises the mentioned error "Table Person has no PK", the generation is working well for my model, just needed to manually remove Person generated entity that shouldn't be actually converted to an entity since it's not a physical table.

@acisser
Copy link
Author

acisser commented Nov 7, 2020

So perhaps the issue is just about skipping the base declaration table from on entity generation and that's all. Everything else is fine.

@Kononnable
Copy link
Owner

Skimmed through docs and it looked like sharing data and schema. If it's just about sharing schema and functionality mostly works it should be much easier to implement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new feature or bug with easy workaround
Projects
None yet
Development

No branches or pull requests

2 participants