Ejemplo n.º 1
0
 private IASTNode CreatePredicateRightValue(MySqlCommandParser.BooleanPrimaryContext ctx, IASTNode rightValue)
 {
     if (rightValue is ColumnSegment)
     {
         return(rightValue);
     }
     return(rightValue is SubQuerySegment subQuerySegment ? new PredicateCompareRightValue(ctx.comparisonOperator().GetText(), new SubQueryExpressionSegment(subQuerySegment))
             : new PredicateCompareRightValue(ctx.comparisonOperator().GetText(), (IExpressionSegment)rightValue));
 }
Ejemplo n.º 2
0
        private IASTNode CreatePredicateRightValue(MySqlCommandParser.BooleanPrimaryContext ctx)
        {
            if (null != ctx.subquery())
            {
                new SubQuerySegment(ctx.Start.StartIndex, ctx.Stop.StopIndex, (SelectCommand)Visit(ctx.subquery()));
            }
            IASTNode rightValue = Visit(ctx.predicate());

            return(CreatePredicateRightValue(ctx, rightValue));
        }
Ejemplo n.º 3
0
        private IASTNode CreateCompareSegment(MySqlCommandParser.BooleanPrimaryContext ctx)
        {
            IASTNode leftValue = Visit(ctx.booleanPrimary());

            if (!(leftValue is ColumnSegment))
            {
                return(leftValue);
            }
            IPredicateRightValue rightValue = (IPredicateRightValue)CreatePredicateRightValue(ctx);

            return(new PredicateSegment(ctx.Start.StartIndex, ctx.Stop.StopIndex, (ColumnSegment)leftValue, rightValue));
        }
Ejemplo n.º 4
0
 public override IASTNode VisitBooleanPrimary(MySqlCommandParser.BooleanPrimaryContext ctx)
 {
     if (null != ctx.comparisonOperator() || null != ctx.SAFE_EQ_())
     {
         return(CreateCompareSegment(ctx));
     }
     if (null != ctx.predicate())
     {
         return(Visit(ctx.predicate()));
     }
     if (null != ctx.subquery())
     {
         return(new SubQuerySegment(ctx.Start.StartIndex, ctx.Stop.StopIndex, (SelectCommand)Visit(ctx.subquery())));
     }
     //TODO deal with IS NOT? (TRUE | FALSE | UNKNOWN | NULL)
     return(new CommonExpressionSegment(ctx.Start.StartIndex, ctx.Stop.StopIndex, ctx.GetText()));
 }