UNPKG

sedk-mysql

Version:
31 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupByStep = void 0; const HavingStep_1 = require("./HavingStep"); const OrderByStep_1 = require("./OrderByStep"); const BaseStep_1 = require("../BaseStep"); class GroupByStep extends BaseStep_1.BaseStep { constructor(prevStep, groupByItems) { super(prevStep); this.groupByItems = groupByItems; if (groupByItems.length === 0) { throw new Error('GroupByStep: groupByItems must not be empty'); } } getStepArtifacts() { return { tables: new Set(), columns: new Set(this.groupByItems) }; } getStepStatement(artifacts = { tables: new Set(), columns: new Set() }) { return `GROUP BY ${this.groupByItems.map(it => it.getStmt(this.data, artifacts)).join(', ')}`; } having(cond1, op1, cond2, op2, cond3) { const havingParts = []; BaseStep_1.BaseStep.addConditionParts(havingParts, cond1, op1, cond2, op2, cond3); return new HavingStep_1.HavingStep(this, havingParts); } orderBy(...orderByItems) { return new OrderByStep_1.OrderByStep(this, orderByItems); } } exports.GroupByStep = GroupByStep; //# sourceMappingURL=GroupByStep.js.map