@sqb/builder
Version:
Extensible multi-dialect SQL query builder written with TypeScript
17 lines (16 loc) • 552 B
JavaScript
import { OperatorType, SerializationType } from '../../enums.js';
import { Operator } from '../operator.js';
export class OpNot extends Operator {
constructor(expression) {
super();
this._operatorType = OperatorType.not;
this._expression = expression;
}
get _type() {
return SerializationType.NEGATIVE_EXPRESSION;
}
_serialize(ctx) {
const expression = ctx.anyToSQL(this._expression);
return ctx.serialize(this._type, expression, () => expression ? 'not ' + expression : '');
}
}