diff --git a/integration-tests/docker-compose.yaml b/integration-tests/docker-compose.yaml index dac8d17e6..2ec611827 100644 --- a/integration-tests/docker-compose.yaml +++ b/integration-tests/docker-compose.yaml @@ -70,3 +70,9 @@ services: # - cockroachdb # restart: on-failure + oracle: + image: container-registry.oracle.com/database/express:21.3.0-xe + environment: + ORACLE_PWD: Pwd2020Db + ports: + - 15006:1521 diff --git a/integration-tests/engines.js b/integration-tests/engines.js index 6ea74f7ab..b1174f11e 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -400,17 +400,35 @@ end;$$`, dbSnapshotBySeconds: true, skipChangeColumn: true, }, + { + label: 'Oracle', + connection: { + engine: 'oracle@dbgate-plugin-oracle', + password: 'Pwd2020Db', + user: 'system', + server: 'oracle', + port: 1521, + serviceName: 'xe', + }, + local: { + server: 'localhost', + port: 15006, + }, + skipOnCI: true, + dbSnapshotBySeconds: true, + }, ]; const filterLocal = [ // filter local testing - 'MySQL', + '-MySQL', '-MariaDB', '-PostgreSQL', '-SQL Server', '-SQLite', '-CockroachDB', '-ClickHouse', + 'Oracle', ]; const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL'); diff --git a/integration-tests/tools.js b/integration-tests/tools.js index 2f9129021..dc4df6a6d 100644 --- a/integration-tests/tools.js +++ b/integration-tests/tools.js @@ -32,12 +32,14 @@ async function connect(engine, database) { return conn; } else { const conn = await driver.connect(connection); - await driver.query(conn, `CREATE DATABASE ${database}`); + const dmp = driver.createDumper(); + dmp.createDatabase(database); + await driver.query(conn, dmp.s); await driver.close(conn); const res = await driver.connect({ ...connection, - database, + database: (driver.dialect.userDatabaseNamePrefix ?? '') + database, }); return res; } @@ -55,12 +57,14 @@ async function prepareConnection(engine, database) { }; } else { const conn = await driver.connect(connection); - await driver.query(conn, `CREATE DATABASE ${database}`); + const dmp = driver.createDumper(); + dmp.createDatabase(database); + await driver.query(conn, dmp.s); await driver.close(conn); return { ...connection, - database, + database: (driver.dialect.userDatabaseNamePrefix ?? '') + database, isPreparedOnly: true, }; } diff --git a/packages/types/dialect.d.ts b/packages/types/dialect.d.ts index c8cbf6384..6ec6205a4 100644 --- a/packages/types/dialect.d.ts +++ b/packages/types/dialect.d.ts @@ -51,6 +51,7 @@ export interface SqlDialect { dropReferencesWhenDropTable?: boolean; requireFromDual?: boolean; + userDatabaseNamePrefix?: string; // c## in Oracle predefinedDataTypes: string[]; diff --git a/plugins/dbgate-plugin-oracle/src/backend/sql/views.js b/plugins/dbgate-plugin-oracle/src/backend/sql/views.js index 423a48ea4..facf4731f 100644 --- a/plugins/dbgate-plugin-oracle/src/backend/sql/views.js +++ b/plugins/dbgate-plugin-oracle/src/backend/sql/views.js @@ -1,13 +1,10 @@ module.exports = ` -select avv.*, - ora_hash("create_sql") as "hash_code" +select avv.* from (select view_name as "pure_name", - -- owner as "schema_name", - -- SUBSTR(text_vc, 1, 3900) AS "create_sql" text as "create_sql" from all_views av - where owner = '$owner' and text is not null + where owner = 'C##test' and text is not null ) avv - where 'views:' || "pure_name" =OBJECT_ID_CONDITION + where 'views:' || "pure_name" is not null `; diff --git a/plugins/dbgate-plugin-oracle/src/frontend/driver.js b/plugins/dbgate-plugin-oracle/src/frontend/driver.js index ed9a87b49..ab745402d 100644 --- a/plugins/dbgate-plugin-oracle/src/frontend/driver.js +++ b/plugins/dbgate-plugin-oracle/src/frontend/driver.js @@ -20,6 +20,7 @@ const dialect = { quoteIdentifier(s) { return '"' + s + '"'; }, + userDatabaseNamePrefix: 'c##', createColumn: true, dropColumn: true,