SYNC: some fixes

This commit is contained in:
SPRINX0\prochazka
2025-02-24 15:18:35 +01:00
committed by Diflow
parent afcb226111
commit 963994b1e5
7 changed files with 31 additions and 8 deletions

View File

@@ -2,6 +2,6 @@ module.exports = {
mysql: true,
postgres: true,
mssql: true,
// oracle: true,
sqlite: true,
// oracle: true,
// sqlite: true,
};

View File

@@ -84,7 +84,7 @@ async function run() {
port: process.env.PORT_oracle,
engine: 'oracle@dbgate-plugin-oracle',
},
'DROP USER C##my_guitar_shop',
'DROP USER c##my_guitar_shop CASCADE',
'CREATE USER c##my_guitar_shop IDENTIFIED BY my_guitar_shop DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA 10M ON users',
'C##my_guitar_shop'
);

View File

@@ -58,6 +58,7 @@
"install:drivers:packer": "node common/defineVolatileDependencies.js packer/build",
"prepare:docker": "yarn plugins:copydist && yarn build:web && yarn build:api && yarn copy:docker:build && yarn install:drivers:docker",
"prepare:packer": "yarn plugins:copydist && yarn build:web && yarn build:api && yarn copy:packer:build",
"build:e2e": "yarn build:lib && yarn prepare:packer",
"start": "concurrently --kill-others-on-fail \"yarn start:api\" \"yarn start:web\"",
"lib": "concurrently --kill-others-on-fail \"yarn start:sqltree\" \"yarn start:filterparser\" \"yarn start:datalib\" \"yarn start:tools\" \"yarn build:plugins:frontend:watch\"",
"ts:api": "yarn workspace dbgate-api ts",

View File

@@ -259,11 +259,21 @@ export class SqlDumper implements AlterProcessor {
this.putRaw(' ');
this.specialColumnOptions(column);
if (includeNullable && !this.dialect?.specificNullabilityImplementation) {
this.put(column.notNull ? '^not ^null' : '^null');
}
if (includeDefault && column.defaultValue?.toString()?.trim()) {
this.columnDefault(column);
if (this.dialect?.defaultValueBeforeNullability) {
if (includeDefault && column.defaultValue?.toString()?.trim()) {
this.columnDefault(column);
}
if (includeNullable && !this.dialect?.specificNullabilityImplementation) {
this.put(column.notNull ? '^not ^null' : '^null');
}
} else {
if (includeNullable && !this.dialect?.specificNullabilityImplementation) {
this.put(column.notNull ? '^not ^null' : '^null');
}
if (includeDefault && column.defaultValue?.toString()?.trim()) {
this.columnDefault(column);
}
}
}

View File

@@ -45,6 +45,10 @@ export function createBulkInsertStreamBase(driver: EngineDriver, stream, dbhan,
logger.info({ sql: dmp.s }, `Creating table ${fullNameQuoted}`);
await driver.script(dbhan, dmp.s);
structure = await driver.analyseSingleTable(dbhan, name);
writable.structure = structure;
}
if (!writable.structure) {
throw new Error(`Error importing table - ${fullNameQuoted} not found`);
}
if (options.truncate) {
await driver.script(dbhan, `TRUNCATE TABLE ${fullNameQuoted}`);

View File

@@ -63,6 +63,7 @@ export interface SqlDialect {
requireFromDual?: boolean;
userDatabaseNamePrefix?: string; // c## in Oracle
upperCaseAllDbObjectNames?: boolean;
defaultValueBeforeNullability?: boolean;
predefinedDataTypes: string[];

View File

@@ -23,6 +23,7 @@ const dialect = {
userDatabaseNamePrefix: 'C##',
upperCaseAllDbObjectNames: true,
requireStandaloneSelectForScopeIdentity: true,
defaultValueBeforeNullability: true,
createColumn: true,
dropColumn: true,
@@ -177,6 +178,12 @@ END trigger_name;
}
return dialect;
},
adaptDataType(dataType) {
if (dataType?.toLowerCase() == 'datetime') return 'timestamp';
if (dataType?.toLowerCase() == 'text') return 'clob';
return dataType;
},
};
module.exports = oracleDriver;