Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema not set in SAP HANA #10622

Closed
1 of 18 tasks
alumni opened this issue Jan 10, 2024 · 1 comment · Fixed by #10624
Closed
1 of 18 tasks

Schema not set in SAP HANA #10622

alumni opened this issue Jan 10, 2024 · 1 comment · Fixed by #10624

Comments

@alumni
Copy link
Contributor

alumni commented Jan 10, 2024

Issue description

The schema from connection options is not set as the current schema

Expected Behavior

I would expect any query that I run via a QueryRunner or directly using the data source to be run in the schema that is set in the data source options (unless, of course, a SET SCHEMA statement is executed).

Actual Behavior

All queries are executed in the user's default schema, regardless of the schema set in data source options.

Steps to reproduce

const connection = new DataSource({
    type: "sap",
    username: "MY_USER",
    schema: "MY_SCHEMA",
    ...
});

await connection.initialize();

console.log(await connection.query(`SELECT CURRENT_SCHEMA FROM SYS.DUMMY`); // returns MY_USER instead of MY_SCHEMA

My Environment

Dependency Version
Operating System any
Node.js version 20.10.0
Typescript version 5.3.3
TypeORM version 0.3.19

Additional Context

Since #10123 was merged, migrations and e.g. QueryRunner.createTable are no longer working when the schema is different than the user name.

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.

@alumni
Copy link
Contributor Author

alumni commented Jun 20, 2024

A workaround for this issue is to add this to connection options:

{
    extra: {
        currentSchema: "MY_SCHEMA"
    }
}

I will create a PR to automatically pass the schema to the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant