UNPKG

@sqb/builder

Version:

Extensible multi-dialect SQL query builder written with TypeScript

41 lines (40 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpBetween = void 0; const enums_js_1 = require("../../enums.js"); const comp_operator_js_1 = require("./comp-operator.js"); class OpBetween extends comp_operator_js_1.CompOperator { _operatorType = enums_js_1.OperatorType.between; _symbol = 'between'; constructor(left, right) { super(left, right); if (right && right[1] == null) right[1] = right[0]; } _serialize(ctx) { if (!(this._right && this._right.length > 0)) return ''; const left = this.__serializeItem(ctx, this._left); const right = [ this.__serializeItem(ctx, this._right[0], true), this.__serializeItem(ctx, this._right[1], true), ]; const o = { operatorType: this._operatorType, symbol: this._symbol, left, right, }; return this.__serialize(ctx, o); } __defaultSerialize(ctx, o) { return (o.left.expression + ' ' + o.symbol + ' ' + o.right[0].expression + ' and ' + o.right[1].expression); } } exports.OpBetween = OpBetween;