Exemplo n.º 1
0
        public static void IndexKeyNotEqualsFirstInSet()
        {
            var firstInSet = IndexRange.FirstInSet;
            var key        = new IndexKey(new [] { SqlObject.BigInt(33), SqlObject.Double(54) });

            Assert.NotEqual(firstInSet, key);
        }
Exemplo n.º 2
0
        public RowTests()
        {
            var tableMock = TableUtil.MockTable("sys.table1", new Dictionary <string, SqlType> {
                { "col1", PrimitiveTypes.VarChar() },
                { "col2", PrimitiveTypes.Double() }
            });

            var values = new SqlObject[][] {
                new SqlObject[] {
                    SqlObject.String("test1"),
                    SqlObject.Double(20.1),
                },
                new SqlObject[] {
                    SqlObject.String("t2"),
                    SqlObject.Double(3.11)
                }
            };

            tableMock.SetupGet(x => x.RowCount)
            .Returns(1);
            tableMock.Setup(x => x.GetValueAsync(It.IsAny <long>(), It.IsInRange(0, 1, Range.Inclusive)))
            .Returns <long, int>((x, y) => Task.FromResult(values[x][y]));

            table = tableMock.Object;
        }
Exemplo n.º 3
0
        public override SqlExpression VisitEqualityExpression(PlSqlParser.EqualityExpressionContext context)
        {
            var left = Visit(context.relationalExpression());

            string op = null;

            if (context.IS().Length > 0)
            {
                if (context.NOT().Length > 0)
                {
                    op = "IS NOT";
                }
                else
                {
                    op = "IS";
                }
            }

            if (String.IsNullOrEmpty(op))
            {
                return(left);
            }

            SqlObject value;

            if (context.EMPTY().Length > 0)
            {
                value = SqlObject.String(SqlString.Empty);
            }
            else if (context.NAN().Length > 0)
            {
                value = SqlObject.Double(double.NaN);
            }
            else if (context.NULL().Length > 0)
            {
                value = SqlObject.Null;
            }
            else if (context.UNKNOWN().Length > 0)
            {
                value = SqlObject.Unknown;
            }
            else if (context.OF().Length > 0)
            {
                // TODO: return TYPEOF function
                throw new NotImplementedException();
            }
            else
            {
                throw new NotSupportedException();
            }

            var right   = SqlExpression.Constant(value);
            var expType = GetBinaryOperator(op);

            return(SqlExpression.Binary(expType, left, right));
        }
Exemplo n.º 4
0
        public InsertSearchTests()
        {
            var leftInfo = new TableInfo(ObjectName.Parse("tab1"));

            leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer()));
            leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean()));
            leftInfo.Columns.Add(new ColumnInfo("c", PrimitiveTypes.Double()));

            left = new TemporaryTable(leftInfo);
            left.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(5563.22) });
            left.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null), SqlObject.Double(921.001) });
            left.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(2010.221) });
        }
Exemplo n.º 5
0
        public static void InsertSort()
        {
            var index = new SortedCollection <SqlObject, long>();
            var items = new BigList <SqlObject>();

            items.Add(SqlObject.Integer(435));
            items.Add(SqlObject.Integer(1920));

            var comparer = new CollectionComparer(items);

            index.InsertSort(SqlObject.Double(2234.99), 45, comparer);

            Assert.Equal(1, index.Count);
        }
Exemplo n.º 6
0
        public LimitedTableTests()
        {
            var leftInfo = new TableInfo(ObjectName.Parse("tab1"));

            leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer()));
            leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean()));
            leftInfo.Columns.Add(new ColumnInfo("c", PrimitiveTypes.Double()));

            var temp = new TemporaryTable(leftInfo);

            temp.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(5563.22) });
            temp.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null), SqlObject.Double(921.001) });
            temp.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(2010.221) });
            temp.BuildIndex();

            left = temp;
        }
Exemplo n.º 7
0
        public async Task MapTwoColumns()
        {
            var subset = new SubsetTable(left, new[] { 1, 2 },
                                         new ObjectName[] { ObjectName.Parse("tab1.b1"), ObjectName.Parse("tab1.c1"), });

            Assert.Equal(3, subset.RowCount);
            Assert.Equal(2, subset.TableInfo.Columns.Count);

            Assert.Equal(0, subset.TableInfo.Columns.IndexOf(ObjectName.Parse("tab1.b1")));
            Assert.Equal(1, subset.TableInfo.Columns.IndexOf(ObjectName.Parse("tab1.c1")));
            Assert.Equal(0, subset.TableInfo.Columns.IndexOf("b1"));
            Assert.Equal(1, subset.TableInfo.Columns.IndexOf("c1"));

            var value1 = await subset.GetValueAsync(0, 1);

            var value2 = await subset.GetValueAsync(2, 0);

            Assert.Equal(SqlObject.Double(5563.22), value1);
            Assert.Equal(SqlObject.Boolean(true), value2);
        }