"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SqlNode_1 = require("./SqlNode");
class IfSqlNode extends SqlNode_1.SqlNode {
    constructor(test, nextNode) {
        super();
        this.test = test;
        this.nextNode = nextNode;
    }
    async getSql(paramMap, parameters = []) {
        this.parameters = parameters;
        // 执行表达式
        const value = new Function(...Object.keys(paramMap), `return ${this.test}`)(...Object.values(paramMap));
        // 判断表达式返回结果是否是true，如果不是则过滤子节点
        if (typeof value === 'boolean' && value) {
            return this.executeChildren(paramMap, parameters);
        }
        if (this.nextNode != null) {
            return this.nextNode.getSql(paramMap, parameters);
        }
        return '';
    }
}
exports.default = IfSqlNode;
//# sourceMappingURL=IfSqlNode.js.map