UNPKG

sedk-mysql

Version:
44 lines 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConditionStep = void 0; const database_1 = require("../database"); const BaseStep_1 = require("./BaseStep"); const models_1 = require("../models"); class ConditionStep extends BaseStep_1.BaseStep { constructor(conditionName, prevStep, whereParts) { super(prevStep); this.conditionName = conditionName; this.whereParts = whereParts; } getStepStatement(artifacts = { tables: new Set(), columns: new Set() }) { if (this.whereParts.length > 0) { BaseStep_1.BaseStep.throwIfConditionPartsInvalid(this.whereParts); const wherePartsString = this.whereParts.map(it => { if (it instanceof models_1.Condition || it instanceof models_1.Expression || it instanceof database_1.BooleanColumn) { return it.getStmt(this.data, artifacts, this.binderStore); } return it.toString(); }); return `${this.conditionName} ${wherePartsString.join(' ')}`; } return ''; } getStepArtifacts() { return { tables: new Set(), columns: new Set(this.getColumns()) }; } getColumns() { return this.whereParts.map(it => { if (it instanceof database_1.BooleanColumn) { return it; } else if (it instanceof models_1.Condition) { return it.getColumns(); } else { return []; } }).flat(1); } } exports.ConditionStep = ConditionStep; //# sourceMappingURL=ConditionStep.js.map