public virtual void Can_add_foreign_key_composite_to_table() { DataClient.AddTable("Something", Column.Int32("id"), Column.Int32("id_2"), Column.String("name") ); DataClient.Add.PrimaryKey("Something_PK").OnColumns("id", "id_2").OfTable("Something"); DataClient.AddTable("Anotherthing", Column.Int32("id").AsPrimaryKey(), Column.Int32("id_Something"), Column.Int32("id_2_Something") ); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.Cascade); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.NoAction); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DataClient.AddForeignKey("fk_Another_Some", "Anotherthing", new string[] { "id_Something", "id_2_Something" }, "Something", new string[] { "id", "id_2" }, OnDelete.SetNull); DataClient.RemoveForeignKey("fk_Another_Some", "Anotherthing"); DropTable("Anotherthing"); DropTable("Something"); }
public virtual void Can_add_named_primary_key_to_table() { DataClient.AddTable(TableFoo, Column.Int32("id").NotNull(), Column.String("name") ); DataClient.AddNamedPrimaryKey(TableFoo, "pk_" + TableFoo, "id"); }
public virtual void Can_create_table_with_column_options() { DataClient.AddTable(TableFoo, Column.Int32("id").NotNull().DefaultValue(1), Column.Int32("id2").AsPrimaryKey(), Column.String("name").NotNull().DefaultValue("foo") ); }
public override void Can_create_table_with_autoIncrement() { Assert.Throws <NotSupportedByDatabaseException>(() => { DataClient.AddTable(TableFoo, Column.AutoIncrement("id"), Column.String("name")); }); }
public virtual void Can_create_table_with_multiple_columns_as_primary_key() { DataClient.AddTable(TableFoo, Column.Int32("id").AsPrimaryKey(), Column.Int32("id2").AsPrimaryKey(), Column.String("name") ); }
public virtual void Can_remove_primary_key_from_table() { DataClient.AddTable(TableFoo, Column.Int32("id").NotNull(), Column.String("name") ); DataClient.AddNamedPrimaryKey(TableFoo, "pk1", "id"); DataClient.RemovePrimaryKey(TableFoo, "pk1"); }
public override void Can_insert_returning_id() { DataClient.AddTable("footable", Column.AutoIncrement("id"), Column.String("name") ); Assert.Equal(1, DataClient.Insert.Into("footable").Columns("name").ValuesAnd("asdf").Return <int>("id")); Assert.Equal(2, DataClient.Insert.Into("footable").Columns("name").ValuesAnd("asdf").Return <int>("id")); Assert.Equal(3, DataClient.Insert.Into("footable").Columns("name").ValuesAnd("asdf").Return <int>("id")); }
public virtual void Can_insert_with_only_null() { DataClient.AddTable("footable", Column.AutoIncrement("id").AsPrimaryKey(), Column.String("name") ); DataClient.Insert.Into("footable").Columns("name").Values(null); var res = DataClient.Select.Columns("name").From("footable").AllRows(); Assert.Null(res[0][0]); }
public virtual void Can_insert_ints_and_strings() { DataClient.AddTable("footable", Column.Int32("colInt"), Column.String("colString")); DataClient.Insert.Into("footable").Columns("colInt", "colString").Values(1, "asdf"); var res = DataClient.Select.Columns("colInt", "colString").From("footable").AllRows(); Assert.True(1 == Convert.ToInt32(res[0][0])); Assert.Equal("asdf", res[0][1]); }
public virtual void Can_add_foreign_key_to_table() { CreateTableFoo(); CreateTableBar(); DataClient.AddTable("foobar", Column.Int32("id").AsPrimaryKey(), Column.Int32("id_bar") ); DataClient.AddForeignKey("fk_foo_bar1", "bar", "id_foo1", "foo", "id", OnDelete.Cascade); DataClient.AddForeignKey("fk_foo_bar2", "bar", "id_foo2", "foo", "id", OnDelete.NoAction); DataClient.AddForeignKey("fk_foobar_bar", "foobar", "id_bar", "bar", "id", OnDelete.SetNull); }
public virtual void Can_insert_dates_and_booleans() { DataClient.AddTable("footable", Column.AutoIncrement("id").AsPrimaryKey(), Column.Date("colDate"), Column.Boolean("colBool")); var now = new DateTime(2017, 1, 1); DataClient.Insert.Into("footable").Columns("colDate", "colBool").Values(now, true); var res = DataClient.Select.Columns("colDate", "colBool").From("footable").AllRows(); Assert.Equal(now.ToString(), res[0][0].ToString()); Assert.Equal(true, res[0][1]); }
public virtual void Can_insert_with_values_plus_null() { DataClient.AddTable("footable", Column.AutoIncrement("id").AsPrimaryKey(), Column.String("name"), Column.String("surname") ); DataClient.Insert.Into("footable").Columns("name", "surname").Values("foo", null); ResultSet res = DataClient.Select.Columns("name", "surname").From("footable").AllRows(); Assert.Equal("foo", res[0][0]); Assert.Null(res[0][1]); }
public override void Can_insert_dates_and_booleans() { DataClient.AddTable("footable", Column.AutoIncrement("id"), Column.Date("colDate"), Column.Boolean("colBool")); var now = DateTime.Now; DataClient.Insert.Into("footable").Columns("colDate", "colBool").Values(now, true); var res = DataClient.Select.Columns("colDate", "colBool").From("footable").AllRows(); Assert.Equal(now.ToString(), res[0][0].ToString()); Assert.Equal((short)1, res[0][1]); }
public virtual void Can_create_table() { DataClient.AddTable(TableFoo, Column.Binary("col_binary"), Column.Boolean("col_boolean"), Column.Date("col_data"), Column.Decimal("col_decimal"), Column.Double("col_double"), Column.Guid("col_guid"), Column.Int16("col_int16"), Column.Int32("col_int32"), Column.Int64("col_int64"), Column.Single("col_single"), Column.String("col_string"), Column.Clob("col_clob") ); }
public virtual void Can_modify_column_from_not_nulable_to_not_nulable() { DataClient.AddTable(TableFoo, Column.Int32("id").AsPrimaryKey(), Column.String("name", 100).NotNull() ); DataClient.Modify .Column("name") .OfTable("foo") .WithDefinition(Column.String("name", 150).NotNull()); var notToLongString = string.Join("", Enumerable.Repeat("V", 150)); var toLongString = string.Join("", Enumerable.Repeat("V", 151)); Assert.ThrowsAny <Exception>(() => DataClient.Insert.Into("foo").Columns("Id", "name").Values(1, DBNull.Value)); DataClient.Insert.Into("foo").Columns("Id", "name").Values(2, notToLongString); Assert.ThrowsAny <Exception>(() => DataClient.Insert.Into("foo").Columns("Id", "name").Values(3, toLongString)); }
public override void Can_bulk_insert_stored_procedure_with_all_items_null() { DataClient.AddTable(TableFoo, Column.Decimal("colDecimal")); try { Database.ExecuteSql("drop procedure pr_bulk"); } catch { } Database.ExecuteSql("create or replace procedure pr_bulk(v_value in float) is begin insert into foo (colDecimal) values (v_value); end pr_bulk;"); var v1s = new decimal?[] { null, null, null, null, null }; Database.ExecuteBulkStoredProcedure("pr_bulk", In.Named("v_value", v1s)); ResultSet res = DataClient.Select .Columns("colDecimal") .From(TableFoo) .AllRows(); Assert.Equal(5, res.Count); }
public override void Can_bulk_insert_stored_procedure() { DataClient.AddTable(TableFoo, Column.Int32("colInt")); try { Database.ExecuteSql("drop procedure pr_bulk"); } catch { } Database.ExecuteSql("create or replace procedure pr_bulk(v_value in number) is begin insert into foo (colInt) values (v_value); end pr_bulk;"); var v1s = new[] { 1, 2, 3, 4 }; Database.ExecuteBulkStoredProcedure("pr_bulk", In.Named("v_value", v1s)); var res = DataClient.Select .Columns("colInt") .From(TableFoo) .AllRows(); Assert.Equal(4, res.Count); }
public override void Can_bulk_insert_stored_procedure_with_nullable_and_dates() { DataClient.AddTable(TableFoo, Column.Decimal("colDecimal"), Column.Date("colDate")); try { Database.ExecuteSql("drop procedure pr_bulkDate"); } catch { } Database.ExecuteSql("create or replace procedure pr_bulkDate(v_value in float, v_date in date) is begin insert into foo (colDecimal, colDate) values (v_value, v_date); end pr_bulkDate;"); var v1s = new decimal?[] { 1, 2, 3, 4, null }; var v2s = new[] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now }; Database.ExecuteBulkStoredProcedure("pr_bulkDate", In.Named("v_value", v1s), In.Named("v_date", v2s)); var res = DataClient.Select .Columns("colDecimal", "colDate") .From(TableFoo) .AllRows(); Assert.Equal(5, res.Count); }
public virtual void Can_create_table_with_autoIncrement_and_schema() { DataClient.AddTable($"{SChema}.{TableFoo}", Column.AutoIncrement("id"), Column.String("name")); }
public virtual void Can_create_table_with_autoIncrement() { DataClient.AddTable(TableFoo, Column.AutoIncrement("id"), Column.String("name")); }
public virtual void Can_create_table_with_autoIncrement_as_primary_key() { DataClient.AddTable(TableFoo, Column.AutoIncrement("id").AsPrimaryKey(), Column.String("name")); }
protected override void ExecuteInternal() { DataClient.AddTable(TableNames[0], _columns); }