mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed import for clickhouse
This commit is contained in:
parent
89c9d5e792
commit
334440f691
@ -37,7 +37,8 @@ export function createBulkInsertStreamBase(driver: EngineDriver, stream, pool, n
|
|||||||
}
|
}
|
||||||
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
dmp.createTable(prepareTableForImport({ ...writable.structure, ...name }));
|
const createdTableInfo = driver.adaptTableInfo(prepareTableForImport({ ...writable.structure, ...name }));
|
||||||
|
dmp.createTable(createdTableInfo);
|
||||||
logger.info({ sql: dmp.s }, `Creating table ${fullNameQuoted}`);
|
logger.info({ sql: dmp.s }, `Creating table ${fullNameQuoted}`);
|
||||||
await driver.script(pool, dmp.s);
|
await driver.script(pool, dmp.s);
|
||||||
structure = await driver.analyseSingleTable(pool, name);
|
structure = await driver.analyseSingleTable(pool, name);
|
||||||
|
@ -177,4 +177,8 @@ export const driverBase = {
|
|||||||
createSaveChangeSetScript(changeSet, dbinfo, defaultCreator) {
|
createSaveChangeSetScript(changeSet, dbinfo, defaultCreator) {
|
||||||
return defaultCreator(changeSet, dbinfo);
|
return defaultCreator(changeSet, dbinfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
adaptTableInfo(table) {
|
||||||
|
return table;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@ -228,6 +228,8 @@ export interface EngineDriver extends FilterBehaviourProvider {
|
|||||||
dbinfo: DatabaseInfo,
|
dbinfo: DatabaseInfo,
|
||||||
defaultCreator: (changeSet: any, dbinfo: DatabaseInfo) => any
|
defaultCreator: (changeSet: any, dbinfo: DatabaseInfo) => any
|
||||||
): any[];
|
): any[];
|
||||||
|
// adapts table info from different source (import, other database) to be suitable for this database
|
||||||
|
adaptTableInfo(table: TableInfo): TableInfo;
|
||||||
|
|
||||||
analyserClass?: any;
|
analyserClass?: any;
|
||||||
dumperClass?: any;
|
dumperClass?: any;
|
||||||
|
@ -6,11 +6,7 @@ const _ = require('lodash');
|
|||||||
* @param {import('dbgate-types').EngineDriver} driver
|
* @param {import('dbgate-types').EngineDriver} driver
|
||||||
*/
|
*/
|
||||||
function createOracleBulkInsertStream(driver, stream, pool, name, options) {
|
function createOracleBulkInsertStream(driver, stream, pool, name, options) {
|
||||||
const writable = createBulkInsertStreamBase(driver, stream, pool, name, {
|
const writable = createBulkInsertStreamBase(driver, stream, pool, name, options);
|
||||||
...options,
|
|
||||||
// this is really not used, send method below is used instead
|
|
||||||
commitAfterInsert: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
writable.send = async () => {
|
writable.send = async () => {
|
||||||
await pool.insert({
|
await pool.insert({
|
||||||
|
@ -17,7 +17,7 @@ class Dumper extends SqlDumper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
columnType(dataType) {
|
columnType(dataType) {
|
||||||
this.putRaw(dataType);
|
this.putRaw(dataType || this.dialect.fallbackDataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
renameColumn(column, newcol) {
|
renameColumn(column, newcol) {
|
||||||
|
@ -189,6 +189,16 @@ const driver = {
|
|||||||
useDatabaseUrl: 1,
|
useDatabaseUrl: 1,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
adaptTableInfo(table) {
|
||||||
|
if (!table.primaryKey && !table.sortingKey) {
|
||||||
|
return {
|
||||||
|
...table,
|
||||||
|
tableEngine: 'Log',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = driver;
|
module.exports = driver;
|
||||||
|
Loading…
Reference in New Issue
Block a user