snack-query-builder
Version:
Query generator for SQL
29 lines • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HavingQueryBuilder = void 0;
const conditional_query_builder_1 = require("./conditional-query-builder");
class HavingQueryBuilder extends conditional_query_builder_1.ConditionalQueryBuilder {
constructor(qb, gb) {
super(qb);
this.$groupBy = gb;
}
end() {
return this.$queryBuilder;
}
toString() {
var _a;
const spaces = this.$queryBuilder.getSpaces();
if (((_a = this.$conditions) === null || _a === void 0 ? void 0 : _a.length) > 0) {
const conditions = this.$conditions.join(`\n${''.padEnd(spaces, ' ')}`);
if (!this.checkParenthesesBalanced(conditions)) {
throw 'Parentheses are not balanced';
}
return `having ${conditions}`;
}
else {
return '';
}
}
}
exports.HavingQueryBuilder = HavingQueryBuilder;
//# sourceMappingURL=having-query-builder.js.map