public override SqlObject VisitLimit_count([NotNull] sqlParser.Limit_countContext context)
        {
            Contract.Requires(context != null);

            SqlLimitSpec sqlLimitSpec;

            if (context.NUMERIC_LITERAL() != null)
            {
                sqlLimitSpec = SqlLimitSpec.Create(
                    SqlNumberLiteral.Create(
                        CstToAstVisitor.GetNumber64ValueFromNode(
                            context.NUMERIC_LITERAL())));
            }
            else if (context.PARAMETER() != null)
            {
                sqlLimitSpec = SqlLimitSpec.Create(
                    SqlParameter.Create(
                        context.PARAMETER().GetText()));
            }
            else
            {
                throw new NotImplementedException();
            }

            return(sqlLimitSpec);
        }
示例#2
0
        public void LEFT()
        {
            // LEFT("Hello", -3)
            AssertEvaluation(
                expected: CosmosString.Empty,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Left,
                    hello,
                    negativeThree));

            // LEFT("Hello", 0)
            AssertEvaluation(
                expected: CosmosString.Empty,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Left,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(0))));

            // LEFT("Hello", 2)
            AssertEvaluation(
                expected: CosmosString.Create("He"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Left,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(2))));

            // LEFT("Hello", 6)
            AssertEvaluation(
                expected: CosmosString.Create("Hello"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Left,
                    hello,
                    six));
        }
        public void SqlBetweenScalarExpressionTest()
        {
            SqlBetweenScalarExpression threeBetweenFourAndFive = SqlBetweenScalarExpression.Create(
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(4)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(3)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(5)),
                not: false);

            AssertEvaluation(CosmosBoolean.Create(true), threeBetweenFourAndFive);

            SqlBetweenScalarExpression threeNotBetweenFourAndFive = SqlBetweenScalarExpression.Create(
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(4)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(3)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(5)),
                not: true);

            AssertEvaluation(CosmosBoolean.Create(false), threeNotBetweenFourAndFive);

            SqlBetweenScalarExpression trueBetweenTrueAndTrueNested = SqlBetweenScalarExpression.Create(
                SqlLiteralScalarExpression.Create(SqlBooleanLiteral.Create(true)),
                threeBetweenFourAndFive,
                threeBetweenFourAndFive,
                not: false);

            AssertEvaluation(CosmosBoolean.Create(true), trueBetweenTrueAndTrueNested);
        }
        public void SqlArrayCreateScalarExpressionTest()
        {
            SqlArrayCreateScalarExpression inner = SqlArrayCreateScalarExpression.Create(
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(1)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(2)),
                SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(3)));

            AssertEvaluation(
                CosmosArray.Create(
                    new List <CosmosElement>()
            {
                CosmosNumber64.Create(1),
                CosmosNumber64.Create(2),
                CosmosNumber64.Create(3),
            }),
                inner);

            SqlArrayCreateScalarExpression outer = SqlArrayCreateScalarExpression.Create(inner);

            AssertEvaluation(
                CosmosArray.Create(
                    new List <CosmosElement>()
            {
                CosmosArray.Create(
                    new List <CosmosElement>()
                {
                    CosmosNumber64.Create(1),
                    CosmosNumber64.Create(2),
                    CosmosNumber64.Create(3),
                })
            }),
                outer);
        }
        public override int Visit(SqlNumberLiteral sqlNumberLiteral)
        {
            int hashCode = SqlNumberLiteralHashCode;

            hashCode = CombineHashes(hashCode, sqlNumberLiteral.Value.GetHashCode());
            return(hashCode);
        }
示例#6
0
        public override SqlObject VisitTop_spec([NotNull] sqlParser.Top_specContext context)
        {
            Contract.Requires(context != null);

            Number64 topCount = CstToAstVisitor.GetNumber64ValueFromNode(context.NUMERIC_LITERAL());

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

            return(first.Value.Equals(second.Value));
        }
        public override SqlObject VisitNumberPathExpression([NotNull] sqlParser.NumberPathExpressionContext context)
        {
            Contract.Requires(context != null);

            SqlPathExpression pathExpression = (SqlPathExpression)this.Visit(context.path_expression());
            SqlNumberLiteral  number         = SqlNumberLiteral.Create(CstToAstVisitor.GetNumber64ValueFromNode(context.NUMERIC_LITERAL()));

            return(SqlNumberPathExpression.Create(pathExpression, number));
        }
示例#9
0
        public void RIGHT()
        {
            // Right("Hello", -3)
            AssertEvaluation(
                expected: CosmosString.Empty,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    negativeThree));

            // Right("Hello", 1.5)
            AssertEvaluation(
                expected: Undefined,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    floatingPoint));

            // Right("Hello", 0)
            AssertEvaluation(
                expected: CosmosString.Empty,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(0))));

            // Right("Hello", 2)
            AssertEvaluation(
                expected: CosmosString.Create("lo"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(2))));

            // Right("Hello", 6)
            AssertEvaluation(
                expected: CosmosString.Create("Hello"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    six));

            // Right("Hello", int.MaxValue + 1)
            AssertEvaluation(
                expected: CosmosString.Create("Hello"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Right,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create((long)int.MaxValue + 1))));
        }
示例#10
0
        public override SqlObject VisitOffset_limit_clause([NotNull] sqlParser.Offset_limit_clauseContext context)
        {
            Contract.Requires(context != null);

            SqlOffsetSpec sqlOffsetSpec = SqlOffsetSpec.Create(
                SqlNumberLiteral.Create(
                    CstToAstVisitor.GetNumber64ValueFromNode(
                        context.offset_count().NUMERIC_LITERAL())));

            SqlLimitSpec sqlLimitSpec = SqlLimitSpec.Create(
                SqlNumberLiteral.Create(
                    CstToAstVisitor.GetNumber64ValueFromNode(
                        context.limit_count().NUMERIC_LITERAL())));

            return(SqlOffsetLimitClause.Create(sqlOffsetSpec, sqlLimitSpec));
        }
示例#11
0
        public QueryUnderConstruction AddOffsetSpec(SqlOffsetSpec offsetSpec, TranslationContext context)
        {
            QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary();

            if (result.offsetSpec != null)
            {
                // Skip(A).Skip(B) => Skip(A + B)
                long offsetA = QueryUnderConstruction.GetOffsetCount(result.offsetSpec);
                long offsetB = QueryUnderConstruction.GetOffsetCount(offsetSpec);
                result.offsetSpec = SqlOffsetSpec.Create(SqlNumberLiteral.Create(offsetA + offsetB));
            }
            else
            {
                result.offsetSpec = offsetSpec;
            }

            return(result);
        }
示例#12
0
        public override SqlObject VisitLiteralScalarExpression([NotNull] sqlParser.LiteralScalarExpressionContext context)
        {
            Contract.Requires(context != null);
            Contract.Requires(context.ChildCount == 1);
            Contract.Requires(context.children[0].ChildCount == 1);

            TerminalNodeImpl terminalNode = (TerminalNodeImpl)(context.children[0].GetChild(0));

            SqlLiteralScalarExpression sqlLiteralScalarExpression;

            switch (terminalNode.Symbol.Type)
            {
            case sqlParser.STRING_LITERAL:
                string value = CstToAstVisitor.GetStringValueFromNode(terminalNode);
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlStringLiteral.Create(value));
                break;

            case sqlParser.NUMERIC_LITERAL:
                Number64 number64 = CstToAstVisitor.GetNumber64ValueFromNode(terminalNode);
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(number64));
                break;

            case sqlParser.K_TRUE:
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlBooleanLiteral.Create(true));
                break;

            case sqlParser.K_FALSE:
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlBooleanLiteral.Create(false));
                break;

            case sqlParser.K_NULL:
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlNullLiteral.Create());
                break;

            case sqlParser.K_UNDEFINED:
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.Create(SqlUndefinedLiteral.Create());
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown symbol type: {terminalNode.Symbol.Type}");
            }

            return(sqlLiteralScalarExpression);
        }
示例#13
0
        private static SqlScalarExpression GenerateMemberIndexerScalarExpressionFromPath(Path path)
        {
            if (path.Length < 1)
            {
                throw new ArgumentException($"{nameof(path)} is too short.");
            }

            if (!(path.First() is StringPathToken rootToken))
            {
                throw new ArgumentException($"{nameof(path)} did not start with a string.");
            }

            SqlScalarExpression rootExpression = SqlPropertyRefScalarExpression.Create(
                member: null,
                identifier: SqlIdentifier.Create(rootToken.PropertyName));

            foreach (PathToken token in path.Skip(1))
            {
                SqlLiteralScalarExpression memberIndexer;
                switch (token)
                {
                case StringPathToken stringPathToken:
                    memberIndexer = SqlLiteralScalarExpression.Create(
                        SqlStringLiteral.Create(
                            stringPathToken.PropertyName));
                    break;

                case IntegerPathToken integerPathToken:
                    memberIndexer = SqlLiteralScalarExpression.Create(
                        SqlNumberLiteral.Create(
                            integerPathToken.Index));
                    break;

                default:
                    throw new ArgumentException($"Unknown token type: {token.GetType()}; {token}");
                }

                rootExpression = SqlMemberIndexerScalarExpression.Create(rootExpression, memberIndexer);
            }

            return(rootExpression);
        }
        public void Unary()
        {
            List <SqlParserBaselineTestInput> inputs = new List <SqlParserBaselineTestInput>();

            // Positive
            foreach (SqlUnaryScalarOperatorKind unaryOperator in (SqlUnaryScalarOperatorKind[])Enum.GetValues(typeof(SqlUnaryScalarOperatorKind)))
            {
                inputs.Add(
                    CreateInput(
                        description: unaryOperator.ToString(),
                        scalarExpression: SqlUnaryScalarExpression.Create(
                            unaryOperator,
                            SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(42))).ToString()));
            }

            // Negative
            inputs.Add(CreateInput(description: "unknown operator", scalarExpression: "$42"));

            this.ExecuteTestSuite(inputs);
        }
示例#15
0
        public void ROUND()
        {
            // ROUND(4.84090499760142E+15)
            // offline engine has double precision errors
            AssertEvaluation(
                expected: CosmosNumber64.Create(4.84090499760142E+15),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Round,
                    SqlLiteralScalarExpression.Create(
                        SqlNumberLiteral.Create(
                            JToken.Parse("4840904997601420").Value <double>()))));

            // ROUND(0.5, 1)
            // -> should round up
            AssertEvaluation(
                expected: CosmosNumber64.Create(1),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Round,
                    SqlLiteralScalarExpression.Create(
                        SqlNumberLiteral.Create(0.5))));
        }
示例#16
0
        /// <summary>
        /// Constructs <see cref="SqlScalarExpression"/> from a geometry <see cref="JToken"/>.
        /// </summary>
        /// <param name="jToken">Json token.</param>
        /// <returns>Instance of <see cref="SqlScalarExpression"/>.</returns>
        private static SqlScalarExpression FromJToken(JToken jToken)
        {
            switch (jToken.Type)
            {
            case JTokenType.Array:
                return(new SqlArrayCreateScalarExpression(jToken.Select(FromJToken).ToArray()));

            case JTokenType.Boolean:
                SqlBooleanLiteral sqlBooleanLiteral = new SqlBooleanLiteral(jToken.Value <bool>());
                return(new SqlLiteralScalarExpression(sqlBooleanLiteral));

            case JTokenType.Null:
                return(new SqlLiteralScalarExpression(new SqlNullLiteral()));

            case JTokenType.String:
                SqlStringLiteral sqlStringLiteral = new SqlStringLiteral(jToken.Value <string>());
                return(new SqlLiteralScalarExpression(sqlStringLiteral));

            case JTokenType.Object:

                var properties =
                    ((JObject)jToken).Properties()
                    .Select(
                        p =>
                        new SqlObjectProperty(
                            new SqlPropertyName(p.Name),
                            FromJToken(p.Value)))
                    .ToArray();

                return(new SqlObjectCreateScalarExpression(properties));

            case JTokenType.Float:
            case JTokenType.Integer:
                SqlNumberLiteral sqlNumberLiteral = new SqlNumberLiteral(jToken.Value <double>());
                return(new SqlLiteralScalarExpression(sqlNumberLiteral));

            default:
                throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.UnexpectedTokenType, jToken.Type));
            }
        }
        public override SqlObject VisitLiteral([NotNull] sqlParser.LiteralContext context)
        {
            TerminalNodeImpl terminalNode = (TerminalNodeImpl)context.children[0];

            SqlLiteral sqlLiteral;

            switch (terminalNode.Symbol.Type)
            {
            case sqlParser.STRING_LITERAL:
                string value = CstToAstVisitor.GetStringValueFromNode(terminalNode);
                sqlLiteral = SqlStringLiteral.Create(value);
                break;

            case sqlParser.NUMERIC_LITERAL:
                Number64 number64 = CstToAstVisitor.GetNumber64ValueFromNode(terminalNode);
                sqlLiteral = SqlNumberLiteral.Create(number64);
                break;

            case sqlParser.K_TRUE:
                sqlLiteral = SqlBooleanLiteral.Create(true);
                break;

            case sqlParser.K_FALSE:
                sqlLiteral = SqlBooleanLiteral.Create(false);
                break;

            case sqlParser.K_NULL:
                sqlLiteral = SqlNullLiteral.Create();
                break;

            case sqlParser.K_UNDEFINED:
                sqlLiteral = SqlUndefinedLiteral.Create();
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown symbol type: {terminalNode.Symbol.Type}");
            }

            return(sqlLiteral);
        }
        public override SqlObject VisitTop_spec([NotNull] sqlParser.Top_specContext context)
        {
            Contract.Requires(context != null);

            SqlTopSpec sqlTopSpec;

            if (context.NUMERIC_LITERAL() != null)
            {
                Number64 topCount = CstToAstVisitor.GetNumber64ValueFromNode(context.NUMERIC_LITERAL());
                sqlTopSpec = SqlTopSpec.Create(SqlNumberLiteral.Create(topCount));
            }
            else if (context.PARAMETER() != null)
            {
                sqlTopSpec = SqlTopSpec.Create(SqlParameter.Create(context.PARAMETER().GetText()));
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(sqlTopSpec);
        }
        public void SqlInScalarExpressionTest()
        {
            SqlLiteralScalarExpression one   = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(1));
            SqlLiteralScalarExpression two   = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(2));
            SqlLiteralScalarExpression three = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(3));

            SqlInScalarExpression oneInOneTwoThree = SqlInScalarExpression.Create(one, false, one, two, three);

            AssertEvaluation(CosmosBoolean.Create(true), oneInOneTwoThree);

            SqlInScalarExpression oneNotInOneTwoThree = SqlInScalarExpression.Create(one, true, one, two, three);

            AssertEvaluation(CosmosBoolean.Create(false), oneNotInOneTwoThree);

            SqlInScalarExpression oneInTwoThree = SqlInScalarExpression.Create(one, false, two, three);

            AssertEvaluation(CosmosBoolean.Create(false), oneInTwoThree);

            SqlInScalarExpression oneNotInTwoThree = SqlInScalarExpression.Create(one, true, two, three);

            AssertEvaluation(CosmosBoolean.Create(true), oneNotInTwoThree);
        }
        public void SqlSubqueryScalarExpressionTest()
        {
            SqlLiteralScalarExpression five  = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(5));
            SqlLiteralScalarExpression three = SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(3));

            // (SELECT VALUE 5 + 3)
            SqlSubqueryScalarExpression subqueryScalarExpression = SqlSubqueryScalarExpression.Create(
                SqlQuery.Create(
                    SqlSelectClause.Create(
                        SqlSelectValueSpec.Create(
                            SqlBinaryScalarExpression.Create(
                                SqlBinaryScalarOperatorKind.Add,
                                five,
                                three))),
                    fromClause: null,
                    whereClause: null,
                    groupByClause: null,
                    orderByClause: null,
                    offsetLimitClause: null));

            AssertEvaluation(CosmosNumber64.Create(5 + 3), subqueryScalarExpression);
        }
示例#21
0
        public void REPLICATE()
        {
            // REPLICATE("Hello", -1)
            // -> undefined
            AssertEvaluation(
                expected: Undefined,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Replicate,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(-1))));

            // REPLICATE("Hello", 1.5)
            // -> REPLICATE("Hello", 1) due to truncation
            AssertEvaluation(
                expected: CosmosString.Create("Hello"),
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Replicate,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(1.5))));

            // REPLICATE("Hello", 10000)
            // -> undefined due to 10kb string cap
            AssertEvaluation(
                expected: Undefined,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Replicate,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(10000))));

            // REPLICATE("Hello", EXP(400))
            // -> undefined due to 10kb string cap
            AssertEvaluation(
                expected: Undefined,
                sqlScalarExpression: SqlFunctionCallScalarExpression.CreateBuiltin(
                    SqlFunctionCallScalarExpression.Identifiers.Replicate,
                    hello,
                    SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(Math.Exp(400)))));
        }
        public void Binary()
        {
            // Positive
            List <SqlParserBaselineTestInput> inputs = new List <SqlParserBaselineTestInput>();

            foreach (SqlBinaryScalarOperatorKind binaryOperator in (SqlBinaryScalarOperatorKind[])Enum.GetValues(typeof(SqlBinaryScalarOperatorKind)))
            {
                inputs.Add(
                    CreateInput(
                        description: binaryOperator.ToString(),
                        scalarExpression: SqlBinaryScalarExpression.Create(
                            binaryOperator,
                            SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(42)),
                            SqlLiteralScalarExpression.Create(SqlNumberLiteral.Create(1337))).ToString()));
            }

            // Order of operations
            inputs.Add(CreateInput(
                           description: "Multiplication, division, and remainder -> left to right",
                           scalarExpression: "1 / 2 * 3 % 4"));
            inputs.Add(CreateInput(
                           description: "Addition and subtraction -> left to right",
                           scalarExpression: "1 + 2 - 3 + 4"));
            inputs.Add(CreateInput(
                           description: "Relational operators -> left to right",
                           scalarExpression: "1 < 2 <= 3 > 4 >= 5"));
            inputs.Add(CreateInput(
                           description: "Equality operators -> left to right",
                           scalarExpression: "1 = 2 != 3 = 4"));
            inputs.Add(CreateInput(
                           description: "Bitwise AND > Bitwise XOR (exclusive or) > Bitwise OR (inclusive or)",
                           scalarExpression: "1 | 2 & 3 ^ 4"));
            inputs.Add(CreateInput(
                           description: "Logical AND > Logical OR",
                           scalarExpression: "1 AND 2 OR 3 AND 4"));
            inputs.Add(CreateInput(
                           description: "Conditional-expression Right to left",
                           scalarExpression: "1 ? 2 : 3 + 4"));
            inputs.Add(CreateInput(
                           description: "Multiplicative > Additive",
                           scalarExpression: "1 + 2 * 3 - 4 / 5"));
            inputs.Add(CreateInput(
                           description: "Additive > Relational",
                           scalarExpression: "1 + 2 < 2 + 3 <= 10 - 4 > 5 >= 3"));
            inputs.Add(CreateInput(
                           description: "Relational > Equality",
                           scalarExpression: "1 > 2 = false AND 1 > 2 != true"));
            inputs.Add(CreateInput(
                           description: "Equality > Bitwise AND",
                           scalarExpression: "1 = 2 & 3 != 4"));
            inputs.Add(CreateInput(
                           description: "Bitwise AND > Bitwise Exclusive OR",
                           scalarExpression: "1 ^ 2 & 3 ^ 4"));
            inputs.Add(CreateInput(
                           description: "Bitwise Exclusive OR > Bitwise Inclusive OR",
                           scalarExpression: "1 | 2 ^ 3 | 4"));
            inputs.Add(CreateInput(
                           description: "Bitwise Inclusive OR > Logical AND",
                           scalarExpression: "1 AND 2 | 3 AND 4"));
            inputs.Add(CreateInput(
                           description: "Logical AND > Logical OR",
                           scalarExpression: "1 OR 2 AND 3 OR 4"));
            inputs.Add(CreateInput(
                           description: "Logical OR > String Concat",
                           scalarExpression: "1 || 2 OR 3 || 4"));

            // Negative
            inputs.Add(CreateInput(description: "Missing Right", scalarExpression: "42 +"));
            inputs.Add(CreateInput(description: "Missing Left", scalarExpression: "AND 1337"));
            inputs.Add(CreateInput(description: "Unknown Operator", scalarExpression: "42 # 1337"));

            this.ExecuteTestSuite(inputs);
        }
 private SqlNumberPathExpression(SqlPathExpression parentPath, SqlNumberLiteral value)
     : base(SqlObjectKind.NumberPathExpression, parentPath)
 {
     this.Value = value;
 }
 public override void Visit(SqlNumberLiteral sqlNumberLiteral)
 {
     SqlObjectTextSerializer.WriteNumber64(this.writer.GetStringBuilder(), sqlNumberLiteral.Value);
 }
示例#25
0
 public override CosmosElement Visit(SqlNumberLiteral literal) => CosmosNumber64.Create(literal.Value);
 public override SqlObject Visit(SqlTopSpec sqlTopSpec)
 {
     return(SqlTopSpec.Create(SqlNumberLiteral.Create(0)));
 }
 public static SqlNumberPathExpression Create(SqlPathExpression parentPath, SqlNumberLiteral value)
 {
     return(new SqlNumberPathExpression(parentPath, value));
 }
示例#28
0
 public abstract void Visit(SqlNumberLiteral literal);
示例#29
0
 public abstract void Visit(SqlNumberLiteral sqlObject);
 public override SqlObject Visit(SqlNumberLiteral sqlNumberLiteral)
 {
     return(SqlNumberLiteral.Create(
                Number64.ToDouble(
                    this.GetObfuscatedNumber(sqlNumberLiteral.Value))));
 }