mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 20:46:01 +00:00
unified prettier
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
import { SqlDumper } from "@dbgate/types";
|
||||
import { Command, Select } from "./types";
|
||||
import { dumpSqlExpression } from "./dumpSqlExpression";
|
||||
import { dumpSqlFromDefinition } from "./dumpSqlSource";
|
||||
import { SqlDumper } from '@dbgate/types';
|
||||
import { Command, Select } from './types';
|
||||
import { dumpSqlExpression } from './dumpSqlExpression';
|
||||
import { dumpSqlFromDefinition } from './dumpSqlSource';
|
||||
|
||||
export function dumpSqlSelect(dmp: SqlDumper, select: Select) {
|
||||
dmp.put("^select ");
|
||||
dmp.put('^select ');
|
||||
if (select.topRecords) {
|
||||
dmp.put("^top %s ", select.topRecords);
|
||||
dmp.put('^top %s ', select.topRecords);
|
||||
}
|
||||
if (select.distinct) {
|
||||
dmp.put("^distinct ");
|
||||
dmp.put('^distinct ');
|
||||
}
|
||||
if (select.selectAll) {
|
||||
dmp.put("* ");
|
||||
dmp.put('* ');
|
||||
}
|
||||
if (select.columns) {
|
||||
if (select.selectAll) dmp.put("&n,");
|
||||
dmp.put("&>&n");
|
||||
dmp.putCollection(",&n", select.columns, fld => {
|
||||
if (select.selectAll) dmp.put('&n,');
|
||||
dmp.put('&>&n');
|
||||
dmp.putCollection(',&n', select.columns, fld => {
|
||||
dumpSqlExpression(dmp, fld.expr);
|
||||
if (fld.alias) dmp.put(" %i", fld.alias);
|
||||
if (fld.alias) dmp.put(' %i', fld.alias);
|
||||
});
|
||||
dmp.put("&n&<");
|
||||
dmp.put('&n&<');
|
||||
}
|
||||
dmp.put("^from ");
|
||||
dmp.put('^from ');
|
||||
dumpSqlFromDefinition(dmp, select.from);
|
||||
if (select.range) {
|
||||
dmp.put("^limit %s ^offset %s ", select.range.limit, select.range.offset);
|
||||
dmp.put('^limit %s ^offset %s ', select.range.limit, select.range.offset);
|
||||
}
|
||||
}
|
||||
|
||||
export function dumpSqlCommand(dmp: SqlDumper, command: Command) {
|
||||
switch (command.commandType) {
|
||||
case "select":
|
||||
case 'select':
|
||||
dumpSqlSelect(dmp, command);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user