Beispiel #1
0
        private IASTNode CreatePredicateRightValue(SqlServerCommandParser.BooleanPrimaryContext context, IASTNode rightValue)
        {
            if (rightValue is ColumnSegment columnSegment)
            {
                return(columnSegment);
            }

            return(rightValue is SubQuerySegment subQuerySegment
                ? new PredicateCompareRightValue(context.comparisonOperator().GetText(), new SubQueryExpressionSegment((SubQuerySegment)rightValue))
                : new PredicateCompareRightValue(context.comparisonOperator().GetText(), (IExpressionSegment)rightValue));
        }
Beispiel #2
0
        private IASTNode CreatePredicateRightValue(SqlServerCommandParser.BooleanPrimaryContext context)
        {
            if (null != context.subquery())
            {
                new SubQuerySegment(context.Start.StartIndex, context.Stop.StopIndex, (SelectCommand)Visit(context.subquery()));
            }

            IASTNode rightValue = Visit(context.predicate());

            return(CreatePredicateRightValue(context, rightValue));
        }
Beispiel #3
0
        private IASTNode CreateCompareSegment(SqlServerCommandParser.BooleanPrimaryContext context)
        {
            IASTNode leftValue = Visit(context.booleanPrimary());

            if (leftValue is ColumnSegment columnSegment)
            {
                var rightValue = (IPredicateRightValue)CreatePredicateRightValue(context);
                return(new PredicateSegment(context.Start.StartIndex, context.Stop.StopIndex, columnSegment, rightValue));
            }
            else
            {
                return(leftValue);
            }
        }
Beispiel #4
0
        public override IASTNode VisitBooleanPrimary(SqlServerCommandParser.BooleanPrimaryContext context)
        {
            if (null != context.comparisonOperator() || null != context.SAFE_EQ_())
            {
                return(CreateCompareSegment(context));
            }

            if (null != context.predicate())
            {
                return(Visit(context.predicate()));
            }

            if (null != context.subquery())
            {
                return(new SubQuerySegment(context.Start.StartIndex, context.Stop.StopIndex, (SelectCommand)Visit(context.subquery())));
            }

            //TODO deal with IS NOT? (TRUE | FALSE | UNKNOWN | NULL)
            return(new CommonExpressionSegment(context.Start.StartIndex, context.Stop.StopIndex, context.GetText()));
        }