@uwdata/mosaic-sql
Version:
SQL query construction and analysis.
52 lines • 1.38 kB
JavaScript
import { UNARY_OPERATOR, UNARY_POSTFIX_OPERATOR } from '../constants.js';
import { ExprNode } from './node.js';
class AbstractUnaryOpNode extends ExprNode {
/** The operator type. */
op;
/** The input expression. */
expr;
/**
* Instantiate an abstract unary operator node.
* @param type The node type.
* @param op The operator type.
* @param expr The input expression.
*/
constructor(type, op, expr) {
super(type);
this.op = op;
this.expr = expr;
}
}
export class UnaryOpNode extends AbstractUnaryOpNode {
/**
* Instantiate a unary operator node.
* @param op The operator type.
* @param expr The input expression.
*/
constructor(op, expr) {
super(UNARY_OPERATOR, op, expr);
}
/**
* Generate a SQL query string for this node.
*/
toString() {
return `(${this.op} ${this.expr})`;
}
}
export class UnaryPostfixOpNode extends AbstractUnaryOpNode {
/**
* Instantiate a unary operator node.
* @param op The operator type.
* @param expr The input expression.
*/
constructor(op, expr) {
super(UNARY_POSTFIX_OPERATOR, op, expr);
}
/**
* Generate a SQL query string for this node.
*/
toString() {
return `(${this.expr} ${this.op})`;
}
}
//# sourceMappingURL=unary-op.js.map