UNPKG

sedk-mysql

Version:
87 lines 3.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OnOrStep = exports.OnAndStep = exports.OnStep = exports.AfterFromStep = void 0; const BaseStep_1 = require("../BaseStep"); const SelectConditionStep_1 = require("./SelectConditionStep"); const OrderByStep_1 = require("./OrderByStep"); const GroupByStep_1 = require("./GroupByStep"); const BaseJoinStep_1 = require("./BaseJoinStep"); const LimitStep_1 = require("./LimitStep"); const LimitWithOffsetStep_1 = require("./LimitWithOffsetStep"); const OffsetStep_1 = require("./OffsetStep"); class AfterFromStep extends BaseStep_1.BaseStep { leftJoin(fromItem) { return new BaseJoinStep_1.LeftJoinStep(this, fromItem); } rightJoin(fromItem) { return new BaseJoinStep_1.RightJoinStep(this, fromItem); } innerJoin(fromItem) { return new BaseJoinStep_1.InnerJoinStep(this, fromItem); } join(fromItem) { return new BaseJoinStep_1.JoinStep(this, fromItem); } limit(offsetOrLimit, limit = undefined) { if (limit === undefined) { return new LimitStep_1.LimitStep(this, offsetOrLimit); } return new LimitWithOffsetStep_1.LimitWithOffsetStep(this, offsetOrLimit, limit); } limit$(offsetOrLimit, limit = undefined) { if (limit === undefined) { return new LimitStep_1.LimitStep(this, offsetOrLimit, true); } return new LimitWithOffsetStep_1.LimitWithOffsetStep(this, offsetOrLimit, limit, true); } offset(value) { return new OffsetStep_1.OffsetStep(this, value); } offset$(value) { return new OffsetStep_1.OffsetStep(this, value, true); } where(condition, operator, middle, operator2, right) { const whereParts = []; BaseStep_1.BaseStep.addConditionParts(whereParts, condition, operator, middle, operator2, right); return new SelectConditionStep_1.SelectWhereStep(this, whereParts); } groupBy(...groupByItems) { return new GroupByStep_1.GroupByStep(this, groupByItems); } orderBy(...orderByItems) { return new OrderByStep_1.OrderByStep(this, orderByItems); } } exports.AfterFromStep = AfterFromStep; class OnStep extends AfterFromStep { constructor(prevStep, condition) { super(prevStep); this.condition = condition; } getStepStatement(artifacts = { tables: new Set(), columns: new Set() }) { return `ON ${this.condition.getStmt(this.data, artifacts, this.binderStore)}`; } getStepArtifacts() { return { tables: new Set(), columns: new Set(this.condition.getColumns()) }; } or(condition) { return new OnOrStep(this, condition); } and(condition) { return new OnAndStep(this, condition); } } exports.OnStep = OnStep; class OnAndStep extends OnStep { getStepStatement(artifacts = { tables: new Set(), columns: new Set() }) { return `AND ${this.condition.getStmt(this.data, artifacts, this.binderStore)}`; } } exports.OnAndStep = OnAndStep; class OnOrStep extends OnStep { getStepStatement(artifacts = { tables: new Set(), columns: new Set() }) { return `OR ${this.condition.getStmt(this.data, artifacts, this.binderStore)}`; } } exports.OnOrStep = OnOrStep; //# sourceMappingURL=AfterFromStep.js.map