plywood
Version:
A query planner and executor
48 lines (47 loc) • 2.1 kB
JavaScript
import { __extends } from "tslib";
import { Ip } from '../datatypes/ip';
import { ChainableExpression, Expression } from './baseExpression';
var IpMatchExpression = (function (_super) {
__extends(IpMatchExpression, _super);
function IpMatchExpression(parameters) {
var _this = _super.call(this, parameters, dummyObject) || this;
_this.ipSearchType = 'ip';
_this._ensureOp('ipMatch');
_this._checkOperandTypes('IP');
_this.ipToSearch = Ip.fromString(parameters.ipToSearch.ip);
_this.ipSearchType = parameters.ipSearchType;
_this.type = 'BOOLEAN';
return _this;
}
IpMatchExpression.fromJS = function (parameters) {
var value = ChainableExpression.jsToValue(parameters);
value.ipToSearch = parameters.ipToSearch;
value.ipSearchType = parameters.ipSearchType;
return new IpMatchExpression(value);
};
IpMatchExpression.prototype.valueOf = function () {
var value = _super.prototype.valueOf.call(this);
value.ipToSearch = Ip.fromString(this.ipToSearch.ip);
value.ipSearchType = this.ipSearchType;
return value;
};
IpMatchExpression.prototype.equals = function (other) {
var _a, _b;
return (_super.prototype.equals.call(this, other) &&
((_a = this.ipToSearch) === null || _a === void 0 ? void 0 : _a.ip) === ((_b = other.ipToSearch) === null || _b === void 0 ? void 0 : _b.ip) &&
this.ipSearchType === other.ipSearchType);
};
IpMatchExpression.prototype.toJS = function () {
var js = _super.prototype.toJS.call(this);
js.ipToSearch = this.ipToSearch;
js.ipSearchType = this.ipSearchType;
return js;
};
IpMatchExpression.prototype._getSQLChainableHelper = function (dialect, operandSQL) {
return dialect.ipMatchExpression(operandSQL, this.ipToSearch.toString(), this.ipSearchType);
};
IpMatchExpression.op = 'ipMatch';
return IpMatchExpression;
}(ChainableExpression));
export { IpMatchExpression };
Expression.register(IpMatchExpression);