Skip to content

[BUG]: view+schema+synchronize broken for oracle #9601

@jjurach

Description

@jjurach

Issue description

view+schema broken for oracle

Expected Behavior

When caller defines schema from connection options and defines a @ViewEntity, the Oracle driver should set that configured schema into typeorm_metadata.schema and should set the view's name into typeorm_metadata.name.

This allows subsequent executions of synchronize to recognize whether the view already exists and not to crash with ORA-00955 errors.

Actual Behavior

When caller defines schema from connection options and defines a @ViewEntity, the Oracle driver incorrectly sets typeorm_metadata.schema to null and typeorm_metadata.name to "${schema}.${view_name}".

This allows synchronize to execute once without apparent problem, but upon subsequent executions, the application produces errors similar to the following:

query failed:CREATE VIEW "myView" AS ...
Error: ORA-00955: name is already used by an existing object

Steps to reproduce

  1. add any @ViewEntity to your project
  2. configure Oracle datasource with a schema set to upper-cased database username
  3. run typeorm schema:sync (or similar) twice against an initially empty Oracle database.

My Environment

Dependency Version
Operating System macos 12.5.1
Node.js version 16.15.1
Typescript version 4.5.2
TypeORM version 0.3.10

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

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