UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

98 lines (97 loc) 4.51 kB
import { SourceExpression } from "./Clause"; import type { SelectQuery } from "./SelectQuery"; import { SqlComponent } from "./SqlComponent"; import { RawString } from "./ValueComponent"; /** * Represents a binary SELECT query (e.g., UNION, INTERSECT, EXCEPT). */ export declare class BinarySelectQuery extends SqlComponent implements SelectQuery { static kind: symbol; left: SelectQuery; operator: RawString; right: SelectQuery; constructor(left: SelectQuery, operator: string, right: SelectQuery); /** * Appends another query to this binary query using UNION as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with UNION * @returns A new BinarySelectQuery representing "(this) UNION query" */ union(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using UNION ALL as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with UNION ALL * @returns A new BinarySelectQuery representing "(this) UNION ALL query" */ unionAll(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using INTERSECT as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with INTERSECT * @returns A new BinarySelectQuery representing "(this) INTERSECT query" */ intersect(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using INTERSECT ALL as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with INTERSECT ALL * @returns A new BinarySelectQuery representing "(this) INTERSECT ALL query" */ intersectAll(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using EXCEPT as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with EXCEPT * @returns A new BinarySelectQuery representing "(this) EXCEPT query" */ except(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using EXCEPT ALL as the operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param query The query to append with EXCEPT ALL * @returns A new BinarySelectQuery representing "(this) EXCEPT ALL query" */ exceptAll(query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using the specified operator. * This creates a new BinarySelectQuery where the left side is this binary query * and the right side is the provided query. * * @param operator SQL operator to use (e.g. 'union', 'union all', 'intersect', 'except') * @param query The query to append with the specified operator * @returns A new BinarySelectQuery representing "(this) [operator] query" */ appendSelectQuery(operator: string, query: SelectQuery): BinarySelectQuery; /** * Appends another query to this binary query using UNION as the operator, accepting a raw SQL string. * This method parses the SQL string and appends the resulting query using UNION. * @param sql The SQL string to parse and union * @returns A new BinarySelectQuery representing "(this) UNION (parsed query)" */ unionRaw(sql: string): BinarySelectQuery; unionAllRaw(sql: string): BinarySelectQuery; intersectRaw(sql: string): BinarySelectQuery; intersectAllRaw(sql: string): BinarySelectQuery; exceptRaw(sql: string): BinarySelectQuery; exceptAllRaw(sql: string): BinarySelectQuery; toSource(alias?: string): SourceExpression; /** * Sets the value of a parameter by name in this query. * @param name Parameter name * @param value Value to set */ setParameter(name: string, value: any): this; }