Skip to content

{ synchronize: false } on ViewEntities #4317

@u8sand

Description

@u8sand

Issue type:

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

Database system/driver:

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

TypeORM version:

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

Steps to reproduce or a small repository showing the problem:

It would be nice if ViewEntities supported the { synchronize: false } option like entities or index. This would enable similar workaround to database-specific feature definitions (i.e. in #1519 an backend-specific index is created which is not synchronized by typeorm directly).

Until #3996 were ready, we could construct the view in a migration and not synchronize it so that we could use the materialize view as a typeorm ViewEntity.

// migration
...
query(`
  create materialized view mymaterializedview as select 1 as id;
`)
...

// materialized view
@ViewEntity('mymaterializedview', { synchronize: false })
class MyMaterializedView {
  @ViewColumn()
  id: string
}

Also note that for this to work, naturally you'd have to specify the name of the view in the ViewEntity definition which I don't believe is currently being done either.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions