示例#1
0
        public void TestValidate()
        {
            // test success
            _andNode.AddChildNode(new SupportExprNode(typeof(Boolean)));
            _andNode.AddChildNode(new SupportExprNode(typeof(Boolean)));
            _andNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container));

            // test failure, type mismatch
            _andNode.AddChildNode(new SupportExprNode(typeof(string)));
            try
            {
                _andNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }

            // test failed - with just one child
            _andNode = new ExprAndNodeImpl();
            _andNode.AddChildNode(new SupportExprNode(typeof(Boolean)));
            try
            {
                _andNode.Validate(SupportExprValidationContextFactory.MakeEmpty(_container));
                Assert.Fail();
            }
            catch (ExprValidationException)
            {
                // Expected
            }
        }
示例#2
0
 private static ExprAndNode MakeValidateAndNode(
     IList<ExprNode> remainingExprNodes,
     FilterSpecCompilerArgs args)
 {
     ExprAndNode andNode = ExprNodeUtilityMake.ConnectExpressionsByLogicalAnd(remainingExprNodes);
     ExprValidationContext validationContext =
         new ExprValidationContextBuilder(
                 args.streamTypeService,
                 args.statementRawInfo,
                 args.compileTimeServices)
             .WithAllowBindingConsumption(true)
             .WithContextDescriptor(args.contextDescriptor)
             .Build();
     andNode.Validate(validationContext);
     return andNode;
 }
示例#3
0
        private ExprNode GetFilterExpressionInclOnClause(ExprNode optionalFilterNode, OuterJoinDesc[] outerJoinDescList)
        {
            if (optionalFilterNode == null)
            {   // no need to add as query planning is fully based on on-clause
                return(null);
            }
            if (outerJoinDescList.Length == 0)
            {  // not an outer-join syntax
                return(optionalFilterNode);
            }
            if (!OuterJoinDesc.ConsistsOfAllInnerJoins(outerJoinDescList))
            {    // all-inner joins
                return(optionalFilterNode);
            }

            var hasOnClauses = OuterJoinDesc.HasOnClauses(outerJoinDescList);

            if (!hasOnClauses)
            {
                return(optionalFilterNode);
            }

            var expressions = new List <ExprNode>();

            expressions.Add(optionalFilterNode);

            foreach (var outerJoinDesc in outerJoinDescList)
            {
                if (outerJoinDesc.OptLeftNode != null)
                {
                    expressions.Add(outerJoinDesc.MakeExprNode(null));
                }
            }

            ExprAndNode andNode = ExprNodeUtility.ConnectExpressionsByLogicalAnd(expressions);

            try
            {
                andNode.Validate(null);
            }
            catch (ExprValidationException ex)
            {
                throw new EPRuntimeException("Unexpected exception validating expression: " + ex.Message, ex);
            }

            return(andNode);
        }
示例#4
0
 private static ExprAndNode MakeValidateAndNode(IList<ExprNode> remainingExprNodes, FilterSpecCompilerArgs args)
 {
     ExprAndNode andNode = ExprNodeUtility.ConnectExpressionsByLogicalAnd(remainingExprNodes);
     var validationContext = new ExprValidationContext(
         args.StreamTypeService,
         args.MethodResolutionService, null,
         args.TimeProvider,
         args.VariableService,
         args.TableService,
         args.ExprEvaluatorContext,
         args.EventAdapterService,
         args.StatementName,
         args.StatementId,
         args.Annotations,
         args.ContextDescriptor,
         args.ScriptingService,
         false, false, true, false, null, false);
     andNode.Validate(validationContext);
     return andNode;
 }