UNPKG

kysely

Version:
108 lines (107 loc) 5.62 kB
/// <reference types="./operation-node-visitor.d.ts" /> import { freeze } from '../util/object-utils.js'; export class OperationNodeVisitor { nodeStack = []; get parentNode() { return this.nodeStack[this.nodeStack.length - 2]; } #visitors = freeze({ AliasNode: this.visitAlias.bind(this), ColumnNode: this.visitColumn.bind(this), IdentifierNode: this.visitIdentifier.bind(this), SchemableIdentifierNode: this.visitSchemableIdentifier.bind(this), RawNode: this.visitRaw.bind(this), ReferenceNode: this.visitReference.bind(this), SelectQueryNode: this.visitSelectQuery.bind(this), SelectionNode: this.visitSelection.bind(this), TableNode: this.visitTable.bind(this), FromNode: this.visitFrom.bind(this), SelectAllNode: this.visitSelectAll.bind(this), AndNode: this.visitAnd.bind(this), OrNode: this.visitOr.bind(this), ValueNode: this.visitValue.bind(this), ValueListNode: this.visitValueList.bind(this), PrimitiveValueListNode: this.visitPrimitiveValueList.bind(this), ParensNode: this.visitParens.bind(this), JoinNode: this.visitJoin.bind(this), OperatorNode: this.visitOperator.bind(this), WhereNode: this.visitWhere.bind(this), InsertQueryNode: this.visitInsertQuery.bind(this), DeleteQueryNode: this.visitDeleteQuery.bind(this), ReturningNode: this.visitReturning.bind(this), CreateTableNode: this.visitCreateTable.bind(this), AddColumnNode: this.visitAddColumn.bind(this), ColumnDefinitionNode: this.visitColumnDefinition.bind(this), DropTableNode: this.visitDropTable.bind(this), DataTypeNode: this.visitDataType.bind(this), OrderByNode: this.visitOrderBy.bind(this), OrderByItemNode: this.visitOrderByItem.bind(this), GroupByNode: this.visitGroupBy.bind(this), GroupByItemNode: this.visitGroupByItem.bind(this), UpdateQueryNode: this.visitUpdateQuery.bind(this), ColumnUpdateNode: this.visitColumnUpdate.bind(this), LimitNode: this.visitLimit.bind(this), OffsetNode: this.visitOffset.bind(this), OnConflictNode: this.visitOnConflict.bind(this), OnDuplicateKeyNode: this.visitOnDuplicateKey.bind(this), CreateIndexNode: this.visitCreateIndex.bind(this), DropIndexNode: this.visitDropIndex.bind(this), ListNode: this.visitList.bind(this), PrimaryKeyConstraintNode: this.visitPrimaryKeyConstraint.bind(this), UniqueConstraintNode: this.visitUniqueConstraint.bind(this), ReferencesNode: this.visitReferences.bind(this), CheckConstraintNode: this.visitCheckConstraint.bind(this), WithNode: this.visitWith.bind(this), CommonTableExpressionNode: this.visitCommonTableExpression.bind(this), CommonTableExpressionNameNode: this.visitCommonTableExpressionName.bind(this), HavingNode: this.visitHaving.bind(this), CreateSchemaNode: this.visitCreateSchema.bind(this), DropSchemaNode: this.visitDropSchema.bind(this), AlterTableNode: this.visitAlterTable.bind(this), DropColumnNode: this.visitDropColumn.bind(this), RenameColumnNode: this.visitRenameColumn.bind(this), AlterColumnNode: this.visitAlterColumn.bind(this), ModifyColumnNode: this.visitModifyColumn.bind(this), AddConstraintNode: this.visitAddConstraint.bind(this), DropConstraintNode: this.visitDropConstraint.bind(this), ForeignKeyConstraintNode: this.visitForeignKeyConstraint.bind(this), CreateViewNode: this.visitCreateView.bind(this), DropViewNode: this.visitDropView.bind(this), GeneratedNode: this.visitGenerated.bind(this), DefaultValueNode: this.visitDefaultValue.bind(this), OnNode: this.visitOn.bind(this), ValuesNode: this.visitValues.bind(this), SelectModifierNode: this.visitSelectModifier.bind(this), CreateTypeNode: this.visitCreateType.bind(this), DropTypeNode: this.visitDropType.bind(this), ExplainNode: this.visitExplain.bind(this), DefaultInsertValueNode: this.visitDefaultInsertValue.bind(this), AggregateFunctionNode: this.visitAggregateFunction.bind(this), OverNode: this.visitOver.bind(this), PartitionByNode: this.visitPartitionBy.bind(this), PartitionByItemNode: this.visitPartitionByItem.bind(this), SetOperationNode: this.visitSetOperation.bind(this), BinaryOperationNode: this.visitBinaryOperation.bind(this), UnaryOperationNode: this.visitUnaryOperation.bind(this), UsingNode: this.visitUsing.bind(this), FunctionNode: this.visitFunction.bind(this), CaseNode: this.visitCase.bind(this), WhenNode: this.visitWhen.bind(this), JSONReferenceNode: this.visitJSONReference.bind(this), JSONPathNode: this.visitJSONPath.bind(this), JSONPathLegNode: this.visitJSONPathLeg.bind(this), JSONOperatorChainNode: this.visitJSONOperatorChain.bind(this), TupleNode: this.visitTuple.bind(this), MergeQueryNode: this.visitMergeQuery.bind(this), MatchedNode: this.visitMatched.bind(this), AddIndexNode: this.visitAddIndex.bind(this), CastNode: this.visitCast.bind(this), FetchNode: this.visitFetch.bind(this), TopNode: this.visitTop.bind(this), }); visitNode = (node) => { this.nodeStack.push(node); this.#visitors[node.kind](node); this.nodeStack.pop(); }; }