UNPKG

ddl-manager

Version:

store postgres procedures and triggers in files

52 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectColumn = void 0; const AbstractAstElement_1 = require("./AbstractAstElement"); const Expression_1 = require("./expression/Expression"); class SelectColumn extends AbstractAstElement_1.AbstractAstElement { constructor(params) { super(); Object.assign(this, params); } static onlyName(columnName) { return new SelectColumn({ name: columnName, expression: Expression_1.Expression.unknown(columnName) }); } clone(params = {}) { return new SelectColumn(Object.assign({ name: this.name, expression: this.expression.clone() }, params)); } replaceExpression(newExpression) { return new SelectColumn({ name: this.name, expression: newExpression }); } replaceTable(replaceTable, toTable) { return new SelectColumn({ name: this.name, expression: this.expression .replaceTable(replaceTable, toTable) }); } template(spaces) { const expression = this.expression.toSQL(spaces.plusOneLevel()); if (expression.trim() === this.name || this.name === "*") { return [expression]; } return [`${expression} as ${this.name}`]; } isAggCall(database) { const funcs = this.expression.getFuncCalls(); return (this.expression.isFuncCall() && database.aggregators.includes(funcs[0].name)); } getAggregations(aggFunctions) { const funcs = this.expression.getFuncCalls(); const aggFuncs = funcs.filter(funcCall => aggFunctions.includes(funcCall.name)); return aggFuncs; } } exports.SelectColumn = SelectColumn; //# sourceMappingURL=SelectColumn.js.map