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));
 }
        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));
        }
        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));
        }
 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()));
 }