public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default) { _pgParser ??= new PgQuery10(); var pgTree = (IPg10Node)_pgParser.Parse(script.Script) ?? throw new QsiException(QsiError.NotSupportedScript, script.ScriptType); switch (script.ScriptType) { case QsiScriptType.Set: return(ActionVisitor.Visit(pgTree)); default: return(TableVisitor.Visit(pgTree)); } }
public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default) { var result = _parser.Parse(script.Script); if (result is TSqlScript sqlScript) { var batch = sqlScript.Batches.FirstOrDefault(); var statement = batch?.Statements?.FirstOrDefault() ?? throw new QsiException(QsiError.Syntax); switch (statement) { case UseStatement useStatement: return(_actionVisitor.VisitUseStatement(useStatement)); case InsertStatement insertStatement: return(_actionVisitor.VisitInsertStatement(insertStatement)); case DeleteStatement deleteStatement: return(_actionVisitor.VisitDeleteStatement(deleteStatement)); case UpdateStatement updateStatement: return(_actionVisitor.VisitUpdateStatement(updateStatement)); case MergeStatement mergeStatement: return(_actionVisitor.VisitMergeStatement(mergeStatement)); case AlterUserStatement alterUserStatement: return(_actionVisitor.VisitAlterUser(alterUserStatement)); case ViewStatementBody viewStatementBody: return(_definitionVisitor.VisitViewStatementBody(viewStatementBody)); default: return(_tableVisitor.Visit(statement)); } } throw new InvalidOperationException(); }
public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default) { var result = _parser.Parse(script.Script); if (result is TSqlScript sqlScript) { var batch = sqlScript.Batches.FirstOrDefault(); var statement = batch?.Statements?.FirstOrDefault() ?? throw new QsiException(QsiError.Syntax); switch (statement) { case UseStatement useStatement: return(_actionVisitor.VisitUseStatement(useStatement)); default: return(_tableVisitor.Visit(statement)); } } throw new InvalidOperationException(); }
public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default) { var statement = CCJSqlParserUtility.Parse(script.Script); return(TableVisitor.Visit(statement) ?? throw new QsiException(QsiError.NotSupportedScript, script.ScriptType)); }