public void Test_can_parse_valid_query_with_where_clause_with_terminator(string query) { CmsqlParser cmsqlParser = CmsqlParserFactory.CreateParserForQuery(query); CmsqlParser.QueryContext parseTree = cmsqlParser.query(); QueryVisitor visitor = new QueryVisitor(); CmsqlQuery cmsqlQuery = visitor.VisitQuery(parseTree); cmsqlQuery.Should().NotBeNull(); cmsqlQuery.ContentType.Should().NotBeNullOrEmpty(); cmsqlQuery.StartNode.Should().NotBeNull(); cmsqlQuery.Criteria.Should().NotBeNull(); }
public override CmsqlQuery VisitQuery(CmsqlParser.QueryContext context) { CmsqlQuery query = new CmsqlQuery(); SelectClauseVisitor selectClauseVisitor = new SelectClauseVisitor(); query.ContentType = context.selectClause().Accept(selectClauseVisitor); FromClauseVisitor fromClauseVisitor = new FromClauseVisitor(); query.StartNode = context.fromClause().Accept(fromClauseVisitor); CmsqlParser.WhereClauseContext whereClauseContext = context.whereClause(); if (whereClauseContext != null) { WhereClauseVisitor whereClauseVisitor = new WhereClauseVisitor(); query.Criteria = whereClauseContext.Accept(whereClauseVisitor); } return(query); }