public void Simple_UseBuilder() { tableName = ObjectName.Parse("APP.test"); AdminQuery.CreateTable(table => table.Named("APP.test") .WithColumn("id", PrimitiveTypes.Integer()) .WithColumn("name", PrimitiveTypes.String())); Assert.IsTrue(AdminQuery.Access().TableExists(tableName)); }
public void WithUserType() { tableName = ObjectName.Parse("APP.test"); var columns = new[] { new SqlTableColumn("id", PrimitiveTypes.Integer()), new SqlTableColumn("t", AdminQuery.Context.ResolveType("APP.test_type")), }; AdminQuery.CreateTable(tableName, columns); Assert.IsTrue(AdminQuery.Access().TableExists(tableName)); }
public void WithIdentity_UseBuilder() { tableName = ObjectName.Parse("APP.test"); AdminQuery.CreateTable(table => table.Named(tableName) .WithIdentityColumn("id", PrimitiveTypes.Integer()) .WithColumn(column => column.Named("name").OfType(PrimitiveTypes.String()).NotNull())); var t = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(t); Assert.AreEqual(2, t.TableInfo.ColumnCount); Assert.IsNotNull(t.TableInfo[0].DefaultExpression); Assert.IsNotNull(AdminQuery.Access().QueryTablePrimaryKey(tableName)); }
public void WithColumnIndex() { tableName = ObjectName.Parse("APP.test"); var columns = new SqlTableColumn[] { new SqlTableColumn("id", PrimitiveTypes.Integer()), new SqlTableColumn("name", PrimitiveTypes.VarChar()) { IndexType = "BLIST" }, new SqlTableColumn("date", PrimitiveTypes.TimeStamp()) { DefaultExpression = SqlExpression.Parse("GetDate()") } }; AdminQuery.CreateTable(tableName, columns); }
public void SimpleCreate() { tableName = ObjectName.Parse("APP.test"); var columns = new SqlTableColumn[] { new SqlTableColumn("id", PrimitiveTypes.Integer()), new SqlTableColumn("name", PrimitiveTypes.VarChar()), }; AdminQuery.CreateTable(tableName, columns); var table = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(table); Assert.AreEqual(2, table.TableInfo.ColumnCount); // TODO: Assert it exists and has the structure desired... }
public void WithIndexedColumn_InsertSearch() { tableName = ObjectName.Parse("APP.test"); var columns = new SqlTableColumn[] { new SqlTableColumn("id", PrimitiveTypes.Integer()), new SqlTableColumn("name", PrimitiveTypes.VarChar()) { IndexType = DefaultIndexTypes.InsertSearch }, }; AdminQuery.CreateTable(tableName, columns); var table = AdminQuery.Access().GetTable(tableName); Assert.IsNotNull(table); Assert.AreEqual(2, table.TableInfo.ColumnCount); }
public void WithColumnDefault() { tableName = ObjectName.Parse("APP.test"); var columns = new SqlTableColumn[] { new SqlTableColumn("id", PrimitiveTypes.Integer()), new SqlTableColumn("name", PrimitiveTypes.VarChar()) { DefaultExpression = SqlExpression.Parse("((67 * 90) + 22)") }, new SqlTableColumn("date", PrimitiveTypes.TimeStamp()) { DefaultExpression = SqlExpression.Parse("GetDate()") } }; AdminQuery.CreateTable(tableName, columns); // TODO: Assert it exists and has the structure desired... }
public void FromMap() { AdminQuery.CreateTable <TestClass>(); tableName = ObjectName.Parse("APP.test_table"); var tableInfo = AdminQuery.Access().GetTableInfo(tableName); Assert.IsNotNull(tableInfo); Assert.AreEqual(3, tableInfo.ColumnCount); var idColumn = tableInfo[0]; Assert.IsNotNull(idColumn); Assert.AreEqual("Id", idColumn.ColumnName); Assert.IsNotNull(idColumn.DefaultExpression); var primaryKey = AdminQuery.Access().QueryTablePrimaryKey(tableName); Assert.IsNotNull(primaryKey); }
public void LogToConsole() { AdminQuery.UseLogger(new ConsoleLogger()); AdminQuery.CreateTable(new ObjectName("test_table"), new [] { new SqlTableColumn("a", PrimitiveTypes.String()) }); }