UNPKG

@uwdata/mosaic-sql

Version:

SQL query construction and analysis.

35 lines 945 B
import { TABLE_REF } from '../constants.js'; import { quoteIdentifier } from '../util/string.js'; import { ExprNode } from './node.js'; /** * Check if a value is a table reference node. * @param value The value to check. */ export function isTableRef(value) { return value instanceof TableRefNode; } export class TableRefNode extends ExprNode { /** The table name, including namespaces. */ table; /** * Instantiate a table reference node. * @param table The table name. */ constructor(table) { super(TABLE_REF); this.table = [table].flat(); } /** * The table name without database or schema namespaces. */ get name() { return this.table[this.table.length - 1]; } /** * Generate a SQL query string for this node. */ toString() { return this.table.map(t => quoteIdentifier(t)).join('.'); } } //# sourceMappingURL=table-ref.js.map