plywood
Version:
A query planner and executor
35 lines (34 loc) • 1.39 kB
JavaScript
import { __extends } from "tslib";
import { Set } from '../datatypes';
import { ChainableExpression, Expression } from './baseExpression';
var AbsoluteExpression = (function (_super) {
__extends(AbsoluteExpression, _super);
function AbsoluteExpression(parameters) {
var _this = _super.call(this, parameters, dummyObject) || this;
_this._ensureOp('absolute');
_this._checkOperandTypes('NUMBER');
_this.type = _this.operand.type;
return _this;
}
AbsoluteExpression.fromJS = function (parameters) {
return new AbsoluteExpression(ChainableExpression.jsToValue(parameters));
};
AbsoluteExpression.prototype._calcChainableHelper = function (operandValue) {
if (operandValue == null)
return null;
return Set.crossUnary(operandValue, function (a) { return Math.abs(a); });
};
AbsoluteExpression.prototype._getSQLChainableHelper = function (dialect, operandSQL) {
return "ABS(".concat(operandSQL, ")");
};
AbsoluteExpression.prototype.specialSimplify = function () {
var operand = this.operand;
if (operand instanceof AbsoluteExpression)
return operand;
return this;
};
AbsoluteExpression.op = 'Absolute';
return AbsoluteExpression;
}(ChainableExpression));
export { AbsoluteExpression };
Expression.register(AbsoluteExpression);