sedk-mysql
Version:
Simple SQL builder and validator for MySQL
42 lines (41 loc) • 1.93 kB
TypeScript
import { BinderStore } from '../binder';
import { FromItem } from './select-path/SelectFromStep';
import { ItemInfo } from '../ItemInfo';
import { ColumnLike } from './select-path/SelectStep';
import { BuilderData } from '../builder';
import { Condition, PrimitiveType } from '../models';
import { LogicalOperator } from '../operators';
import { BooleanColumn, Column, Table } from '../database';
export declare enum Parenthesis {
Open = "(",
Close = ")"
}
export type Artifacts = {
tables: ReadonlySet<Table>;
columns: ReadonlySet<Column>;
};
export declare abstract class BaseStep extends Function {
readonly prevStep: BaseStep | null;
readonly rootStep: BaseStep;
protected readonly data: BuilderData;
protected readonly binderStore: BinderStore;
protected readonly prefixSeparator: string;
constructor(prevStep: BaseStep | null);
getSQL(): string;
protected getFullStatement(nextArtifacts: Artifacts): string;
protected getFullArtifacts(): Artifacts;
private mergeArtifacts;
abstract getStepStatement(artifacts: Artifacts): string;
abstract getStepArtifacts(): Artifacts;
private getStepStatementCalled;
getBindValues(): PrimitiveType[];
protected static getTable(item: FromItem): Table;
protected throwIfTableNotInDb(table: Table): void;
protected throwIfColumnsNotInDb(columns: (ItemInfo | ColumnLike)[]): void;
protected static addConditionParts(conditionArray: (LogicalOperator | Condition | Parenthesis | BooleanColumn)[], cond1: Condition, op1?: LogicalOperator, cond2?: Condition, op2?: LogicalOperator, cond3?: Condition): void;
/**
* This function throws error if WhereParts Array where invalid
* it check the number of open and close parentheses in the conditions
*/
protected static throwIfConditionPartsInvalid(conditionsArray: (LogicalOperator | Condition | Parenthesis | BooleanColumn)[]): void;
}