unified prettier

This commit is contained in:
Jan Prochazka
2020-03-05 13:32:42 +01:00
parent 9ef719ec95
commit ffe8f1027f
12 changed files with 88 additions and 100 deletions

View File

@@ -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;
}