public override void Visit(SqlExistsScalarExpression sqlExistsScalarExpression)
 {
     this.writer.Write("EXISTS");
     this.WriteStartContext("(");
     sqlExistsScalarExpression.Subquery.Accept(this);
     this.WriteEndContext(")");
 }
        public override int Visit(SqlExistsScalarExpression sqlExistsScalarExpression)
        {
            int hashCode = SqlExistsScalarExpressionHashCode;

            hashCode = CombineHashes(hashCode, sqlExistsScalarExpression.Subquery.Accept(this));
            return(hashCode);
        }
예제 #3
0
        public override CosmosElement Visit(SqlExistsScalarExpression scalarExpression, CosmosElement document)
        {
            // Only run on the current document since the subquery is always correlated.
            IEnumerable <CosmosElement> subqueryResults = SqlInterpreter.ExecuteQuery(
                new CosmosElement[] { document },
                scalarExpression.Subquery);

            return(CosmosBoolean.Create(subqueryResults.Any()));
        }
        public override SqlObject VisitExistsScalarExpression([NotNull] sqlParser.ExistsScalarExpressionContext context)
        {
            Contract.Requires(context != null);
            // K_EXISTS '(' sql_query ')'
            Contract.Requires(context.ChildCount == 4);

            SqlQuery subquery = (SqlQuery)this.Visit(context.children[2]);

            return(SqlExistsScalarExpression.Create(subquery));
        }
        public override bool Visit(SqlExistsScalarExpression first, SqlObject secondAsObject)
        {
            if (!(secondAsObject is SqlExistsScalarExpression second))
            {
                return(false);
            }

            if (!Equals(first.Subquery, second.Subquery))
            {
                return(false);
            }

            return(true);
        }
예제 #6
0
 public abstract void Visit(SqlExistsScalarExpression sqlObject);
 public override SqlObject Visit(SqlExistsScalarExpression sqlExistsScalarExpression)
 {
     return(SqlExistsScalarExpression.Create(sqlExistsScalarExpression.Subquery.Accept(this) as SqlQuery));
 }
 public abstract void Visit(SqlExistsScalarExpression scalarExpression);
예제 #9
0
 public override bool Visit(SqlExistsScalarExpression sqlExistsScalarExpression)
 {
     // No need to worry about aggregates within the subquery (they will recursively get rewritten).
     return(false);
 }
예제 #10
0
 public abstract TResult Visit(SqlExistsScalarExpression sqlObject);
        public void SqlExistsScalarExpressionTest()
        {
            CosmosObject tag = CosmosObject.Create(new Dictionary <string, CosmosElement>
            {
                ["name"] = CosmosString.Create("asdf")
            });

            CosmosObject tags = CosmosObject.Create(new Dictionary <string, CosmosElement>
            {
                ["tags"] = CosmosArray.Create(new List <CosmosElement>()
                {
                    tag
                }),
                ["_rid"] = CosmosString.Create("AYIMAMmFOw8YAAAAAAAAAA==")
            });

            CosmosObject tagsWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement>
            {
                ["c"]    = tags,
                ["_rid"] = CosmosString.Create("AYIMAMmFOw8YAAAAAAAAAA==")
            });

            // EXISTS(SELECT VALUE t.name FROM t in c.tags where t.name = "asdf")
            SqlExistsScalarExpression existsScalarExpressionMatched = SqlExistsScalarExpression.Create(
                SqlQuery.Create(
                    SqlSelectClause.Create(
                        SqlSelectValueSpec.Create(
                            TestUtils.CreatePathExpression("t", "name"))),
                    SqlFromClause.Create(
                        SqlArrayIteratorCollectionExpression.Create(
                            SqlIdentifier.Create("t"),
                            SqlInputPathCollection.Create(
                                SqlIdentifier.Create("c"),
                                SqlStringPathExpression.Create(
                                    null,
                                    SqlStringLiteral.Create("tags"))))),
                    SqlWhereClause.Create(
                        SqlBinaryScalarExpression.Create(
                            SqlBinaryScalarOperatorKind.Equal,
                            TestUtils.CreatePathExpression("t", "name"),
                            SqlLiteralScalarExpression.Create(SqlStringLiteral.Create("asdf")))),
                    groupByClause: null,
                    orderByClause: null,
                    offsetLimitClause: null));

            AssertEvaluation(CosmosBoolean.Create(true), existsScalarExpressionMatched, tagsWrapped);

            SqlExistsScalarExpression existsScalarExpressionNotMatched = SqlExistsScalarExpression.Create(
                SqlQuery.Create(
                    SqlSelectClause.Create(
                        SqlSelectValueSpec.Create(
                            TestUtils.CreatePathExpression("t", "name"))),
                    SqlFromClause.Create(
                        SqlArrayIteratorCollectionExpression.Create(
                            SqlIdentifier.Create("t"),
                            SqlInputPathCollection.Create(
                                SqlIdentifier.Create("c"),
                                SqlStringPathExpression.Create(
                                    null,
                                    SqlStringLiteral.Create("tags"))))),
                    SqlWhereClause.Create(
                        SqlBinaryScalarExpression.Create(
                            SqlBinaryScalarOperatorKind.NotEqual,
                            TestUtils.CreatePathExpression("t", "name"),
                            SqlLiteralScalarExpression.Create(SqlStringLiteral.Create("asdf")))),
                    groupByClause: null,
                    orderByClause: null,
                    offsetLimitClause: null));

            AssertEvaluation(CosmosBoolean.Create(false), existsScalarExpressionNotMatched, tagsWrapped);
        }
예제 #12
0
 public override bool Visit(SqlExistsScalarExpression scalarExpression)
 {
     return(false);
 }
예제 #13
0
 public abstract TOutput Visit(SqlExistsScalarExpression sqlObject, TArg input);
예제 #14
0
 public abstract TResult Visit(SqlExistsScalarExpression scalarExpression);