This commit is contained in:
Jan Prochazka 2020-11-28 08:27:40 +01:00
parent b1ccd16870
commit 9c9c82a547
5 changed files with 13 additions and 8 deletions

View File

@ -139,6 +139,7 @@ module.exports = {
}
for (const packageName of preinstallPlugins) {
if (this.removedPlugins.includes(packageName)) continue;
if (installed.find((x) => x.name == packageName)) continue;
try {
console.log('Preinstalling plugin', packageName);
await this.install({ packageName });

View File

@ -1,4 +1,4 @@
const { quoteFullName } = require('dbgate-tools');
const { quoteFullName, fullNameToString } = require('dbgate-tools');
const requireEngineDriver = require('../utility/requireEngineDriver');
async function tableReader({ connection, pureName, schemaName }) {
@ -11,13 +11,15 @@ async function tableReader({ connection, pureName, schemaName }) {
const table = await driver.analyseSingleObject(pool, fullName, 'tables');
const query = `select * from ${quoteFullName(driver.dialect, fullName)}`;
if (table) {
console.log(`Reading table ${table.pureName}`);
// @ts-ignore
console.log(`Reading table ${fullNameToString(table)}`);
// @ts-ignore
return await driver.readQuery(pool, query, table);
}
const view = await driver.analyseSingleObject(pool, fullName, 'views');
if (view) {
console.log(`Reading view ${view.pureName}`);
// @ts-ignore
console.log(`Reading view ${fullNameToString(view)}`);
// @ts-ignore
return await driver.readQuery(pool, query, view);
}

View File

@ -1,7 +1,8 @@
const requireEngineDriver = require("../utility/requireEngineDriver");
const { fullNameToString } = require('dbgate-tools');
const requireEngineDriver = require('../utility/requireEngineDriver');
async function tableWriter({ connection, schemaName, pureName, ...options }) {
console.log(`Write table ${schemaName}.${pureName}`);
console.log(`Writing table ${fullNameToString({ schemaName, pureName })}`);
const driver = requireEngineDriver(connection);
const pool = await driver.connect(connection);

View File

@ -43,7 +43,7 @@ export function createBulkInsertStreamBase(driver, stream, pool, name, options):
await driver.query(pool, `TRUNCATE TABLE ${fullNameQuoted}`);
}
this.columnNames = _intersection(
writable.columnNames = _intersection(
structure.columns.map((x) => x.columnName),
writable.structure.columns.map((x) => x.columnName)
);
@ -56,14 +56,14 @@ export function createBulkInsertStreamBase(driver, stream, pool, name, options):
const dmp = driver.createDumper();
dmp.putRaw(`INSERT INTO ${fullNameQuoted} (`);
dmp.putCollection(',', this.columnNames, (col) => dmp.putRaw(driver.dialect.quoteIdentifier(col)));
dmp.putCollection(',', writable.columnNames, (col) => dmp.putRaw(driver.dialect.quoteIdentifier(col)));
dmp.putRaw(')\n VALUES\n');
let wasRow = false;
for (const row of rows) {
if (wasRow) dmp.putRaw(',\n');
dmp.putRaw('(');
dmp.putCollection(',', this.columnNames, (col) => dmp.putValue(row[col]));
dmp.putCollection(',', writable.columnNames, (col) => dmp.putValue(row[col]));
dmp.putRaw(')');
wasRow = true;
}

View File

@ -104,6 +104,7 @@ export function useAppObjectParams() {
setOpenedConnections,
config,
showModal,
extensions,
};
}