@uwdata/mosaic-sql
Version:
SQL query construction and analysis.
33 lines (28 loc) • 687 B
text/typescript
import type { ParamLike } from '../types.js';
import { PARAM } from '../constants.js';
import { literalToSQL } from './literal.js';
import { ExprNode } from './node.js';
export class ParamNode extends ExprNode {
/** The dynamic parameter. */
readonly param: ParamLike;
/**
* Instantiate a param node with a dynamic parameter.
* @param param The dynamic parameter.
*/
constructor(param: ParamLike) {
super(PARAM);
this.param = param;
}
/**
* Returns the current parameter value.
*/
get value() {
return this.param.value;
}
/**
* Generate a SQL query string for this node.
*/
toString() {
return literalToSQL(this.value);
}
}