mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
Merge branch 'master' of https://github.com/dbgate/dbgate
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import _compact from 'lodash/compact';
|
||||
import _isString from 'lodash/isString';
|
||||
import { SqlDumper } from './SqlDumper';
|
||||
import { splitQuery } from 'dbgate-query-splitter';
|
||||
import { dumpSqlSelect } from 'dbgate-sqltree';
|
||||
@@ -26,9 +27,17 @@ const dialect = {
|
||||
defaultSchemaName: null,
|
||||
};
|
||||
|
||||
export async function runCommandOnDriver(pool, driver: EngineDriver, cmd: (dmp: SqlDumper) => void): Promise<void> {
|
||||
export async function runCommandOnDriver(
|
||||
pool,
|
||||
driver: EngineDriver,
|
||||
cmd: (dmp: SqlDumper) => void | string
|
||||
): Promise<void> {
|
||||
const dmp = driver.createDumper();
|
||||
cmd(dmp as any);
|
||||
if (_isString(cmd)) {
|
||||
dmp.put(cmd);
|
||||
} else {
|
||||
cmd(dmp as any);
|
||||
}
|
||||
// console.log('CMD:', dmp.s);
|
||||
await driver.query(pool, dmp.s, { discardResult: true });
|
||||
}
|
||||
@@ -39,11 +48,21 @@ export async function runQueryOnDriver(
|
||||
cmd: (dmp: SqlDumper) => void
|
||||
): Promise<QueryResult> {
|
||||
const dmp = driver.createDumper();
|
||||
cmd(dmp as any);
|
||||
if (_isString(cmd)) {
|
||||
dmp.put(cmd);
|
||||
} else {
|
||||
cmd(dmp as any);
|
||||
}
|
||||
// console.log('QUERY:', dmp.s);
|
||||
return await driver.query(pool, dmp.s);
|
||||
}
|
||||
|
||||
export function formatQueryWithoutParams(driver: EngineDriver, sql: string) {
|
||||
const dmp = driver.createDumper();
|
||||
dmp.put(sql);
|
||||
return dmp.s;
|
||||
}
|
||||
|
||||
export const driverBase = {
|
||||
analyserClass: null,
|
||||
dumperClass: SqlDumper,
|
||||
|
||||
Reference in New Issue
Block a user