Beispiel #1
0
 private bool IsDistinct(MySqlCommandParser.SelectClauseContext ctx)
 {
     foreach (MySqlCommandParser.SelectSpecificationContext each in ctx.selectSpecification())
     {
         if (((BooleanLiteralValue)Visit(each)).GetValue())
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        public override IASTNode VisitSelectClause(MySqlCommandParser.SelectClauseContext ctx)
        {
            SelectCommand result = new SelectCommand();

            result.Projections = (ProjectionsSegment)Visit(ctx.projections());
            if (null != ctx.selectSpecification())
            {
                result.Projections.SetDistinctRow(IsDistinct(ctx));
            }
            if (null != ctx.fromClause())
            {
                CollectionValue <TableReferenceSegment> tableReferences = (CollectionValue <TableReferenceSegment>)Visit(ctx.fromClause());
                foreach (TableReferenceSegment each in tableReferences.GetValue())
                {
                    result.TableReferences.Add(each);
                }
            }
            if (null != ctx.whereClause())
            {
                result.Where = (WhereSegment)Visit(ctx.whereClause());
            }
            if (null != ctx.groupByClause())
            {
                result.GroupBy = (GroupBySegment)Visit(ctx.groupByClause());
            }
            if (null != ctx.orderByClause())
            {
                result.OrderBy = (OrderBySegment)Visit(ctx.orderByClause());
            }
            if (null != ctx.limitClause())
            {
                result.Limit = (LimitSegment)Visit(ctx.limitClause());
            }
            if (null != ctx.lockClause())
            {
                result.Lock = (LockSegment)Visit(ctx.lockClause());
            }
            return(result);
        }