示例#1
0
        public void CreateTable_With_Counter_Static()
        {
            var config = new MappingConfiguration()
                         .Define(new Map <AllTypesEntity>().ExplicitColumns()
                                 .TableName("tbl_with_counter_static")
                                 .PartitionKey(t => t.UuidValue)
                                 .ClusteringKey(t => t.StringValue)
                                 .Column(t => t.UuidValue, cm => cm.WithName("id1"))
                                 .Column(t => t.StringValue, cm => cm.WithName("id2"))
                                 .Column(t => t.Int64Value, cm => cm.WithName("counter_col1")
                                         .AsCounter().AsStatic())
                                 .Column(t => t.IntValue, cm => cm.WithName("counter_col2")
                                         .AsCounter()));
            var table = new Table <AllTypesEntity>(Session, config);

            table.Create();

            VerifyStatement(
                QueryType.Query,
                "CREATE TABLE tbl_with_counter_static (" +
                "counter_col1 counter static, counter_col2 counter, id1 uuid, id2 text, " +
                "PRIMARY KEY (id1, id2))",
                1);

            PrimeSystemSchemaTables(
                _uniqueKsName,
                "tbl_with_counter_static",
                new []
            {
                new StubTableColumn("counter_col1", StubColumnKind.Regular, DataType.Counter),
                new StubTableColumn("counter_col2", StubColumnKind.Regular, DataType.Counter),
                new StubTableColumn("id1", StubColumnKind.PartitionKey, DataType.Uuid),
                new StubTableColumn("id2", StubColumnKind.ClusteringKey, DataType.Text)
            });

            SessionCluster.RefreshSchema(_uniqueKsName, "tbl_with_counter_static");

            var tableMeta = SessionCluster.Metadata.GetTable(_uniqueKsName, "tbl_with_counter_static");

            Assert.AreEqual(4, tableMeta.TableColumns.Length);
        }
示例#2
0
        public void CreateTable_With_Frozen_Tuple()
        {
            var config = new MappingConfiguration().Define(new Map <UdtAndTuplePoco>()
                                                           .PartitionKey(p => p.Id1)
                                                           .Column(p => p.Id1)
                                                           .Column(p => p.Tuple1, cm => cm.WithName("t").AsFrozen())
                                                           .TableName("tbl_frozen_tuple")
                                                           .ExplicitColumns());
            var table = new Table <UdtAndTuplePoco>(Session, config);

            table.Create();

            VerifyStatement(
                QueryType.Query,
                "CREATE TABLE tbl_frozen_tuple (Id1 uuid, t frozen<tuple<bigint, bigint, text>>, PRIMARY KEY (Id1))",
                1);

            PrimeSystemSchemaTables(
                _uniqueKsName,
                "tbl_frozen_tuple",
                new []
            {
                new StubTableColumn("Id1", StubColumnKind.PartitionKey, DataType.Uuid),
                new StubTableColumn("t", StubColumnKind.Regular, DataType.Frozen(DataType.Tuple(DataType.BigInt, DataType.BigInt, DataType.Text)))
            });

            SessionCluster.RefreshSchema(_uniqueKsName, "tbl_frozen_tuple");

            var tableMeta = SessionCluster.Metadata.GetTable(_uniqueKsName, "tbl_frozen_tuple");

            Assert.NotNull(tableMeta);
            Assert.AreEqual(2, tableMeta.TableColumns.Length);
            var column = tableMeta.ColumnsByName["t"];

            Assert.AreEqual(ColumnTypeCode.Tuple, column.TypeCode);
        }