ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
[Migration Generator]: Error when updating view-expression of view that has dependent objects
Expected Behavior
When updating a view, it should drop all dependent views in the right order before it drops and recreates the actual view that should be changed and rebuild them again afterwards.
Actual Behavior
Only the view thats beeing edited is beeing dropped, which results in an error because there are dependent objects:
QueryFailedError: cannot drop view demo_view_entity because other objects depend on it
This will create 4 Entities: 2 tables and 2 views.
If you update the expression of the DemoViewEntity to:
@ViewEntity({
expression: `
SELECT
DEO.id AS id,
DEO.property AS property,
DET.some_other_property AS some_other_property,
NULL AS new_column,
NULL AS new_column_2
FROM
demo_entity_one DEO
LEFT JOIN
demo_entity_two DET ON DET.demo_entity_one_id = DEO.id
`,
})
and run the typeorm schema:log you will see, that only the DemoViewEntity will be dropped, which will result in an error cause of the dependent view.
This would be the expected behavior:
Drop DemoViewEntityChild
Drop DemoViewEntity
Recreate DemoViewEntity
Recreate DemoViewEntityChild
My Environment
Dependency
Version
Operating System
Node.js version
^14
Typescript version
4.3.5
TypeORM version
0.2.37
Additional Context
Relevant Database Driver(s)
DB Type
Reproducible
aurora-data-api
no
aurora-data-api-pg
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
sqlite
no
sqlite-abstract
no
sqljs
no
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✖️ Yes, I have the time, and I know how to start.
✅ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Description:
[Migration Generator]: Error when updating view-expression of view that has dependent objects
Expected Behavior
When updating a view, it should drop all dependent views in the right order before it drops and recreates the actual view that should be changed and rebuild them again afterwards.
Actual Behavior
Only the view thats beeing edited is beeing dropped, which results in an error because there are dependent objects:
Steps to Reproduce
Please checkout and run this demo repo: https://github.com/jonahlk/typeorm-view-bug
This will create 4 Entities: 2 tables and 2 views.
If you update the expression of the
DemoViewEntity
to:and run the
typeorm schema:log
you will see, that only theDemoViewEntity
will be dropped, which will result in an error cause of the dependent view.This would be the expected behavior:
My Environment
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?