Skip to content

Commit e5e7897

Browse files
committed
fix(sap): rename schema
1 parent 8936e82 commit e5e7897

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/driver/sap/SapDriver.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,9 @@ export class SapDriver implements Driver {
302302

303303
const queryRunner = this.createQueryRunner("master")
304304

305-
this.version = await queryRunner.getVersion()
306-
307-
if (!this.database) {
308-
this.database = await queryRunner.getCurrentDatabase()
309-
}
305+
const { version, database } = await queryRunner.getDatabaseAndVersion()
306+
this.version = version
307+
this.database = database
310308

311309
if (!this.schema) {
312310
this.schema = await queryRunner.getCurrentSchema()

src/driver/sap/SapQueryRunner.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,16 @@ export class SapQueryRunner extends BaseQueryRunner implements QueryRunner {
396396
/**
397397
* Returns the database server version.
398398
*/
399-
async getVersion(): Promise<string> {
400-
const currentDBQuery: [{ version: string }] = await this.query(
401-
`SELECT "VERSION" AS "version" FROM "SYS"."M_DATABASE"`,
402-
)
399+
async getDatabaseAndVersion(): Promise<{
400+
database: string
401+
version: string
402+
}> {
403+
const currentDBQuery: [{ database: string; version: string }] =
404+
await this.query(
405+
`SELECT "DATABASE_NAME" AS "database", "VERSION" AS "version" FROM "SYS"."M_DATABASE"`,
406+
)
403407

404-
return currentDBQuery[0].version
408+
return currentDBQuery[0]
405409
}
406410

407411
/**
@@ -674,14 +678,14 @@ export class SapQueryRunner extends BaseQueryRunner implements QueryRunner {
674678
upQueries.push(
675679
new Query(
676680
`RENAME TABLE ${this.escapePath(oldTable)} TO ${this.escapePath(
677-
newTableName,
681+
newTable,
678682
)}`,
679683
),
680684
)
681685
downQueries.push(
682686
new Query(
683687
`RENAME TABLE ${this.escapePath(newTable)} TO ${this.escapePath(
684-
oldTableName,
688+
oldTable,
685689
)}`,
686690
),
687691
)

0 commit comments

Comments
 (0)