Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer the DbAdapter from the DbConnection #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var respawner = await Respawner.CreateAsync(connection, new RespawnerOptions
{
"public"
},
DbAdapter = DbAdapter.Postgres
DbAdapter = DbAdapter.Postgres // 👈 optional, inferred from the connection for SQL Server, PostgreSQL, MySQL, Oracle and Informix
});
```

Expand Down
8 changes: 0 additions & 8 deletions Respawn.DatabaseTests/InformixTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public async Task ShouldDeleteData()

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" }
});
await checkPoint.ResetAsync(_connection);
Expand All @@ -99,7 +98,6 @@ public async Task ShouldIgnoreTables()
}
var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions()
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" },
TablesToIgnore = new Table[] { "foo" }
});
Expand Down Expand Up @@ -140,7 +138,6 @@ FOREIGN KEY (FooValue) REFERENCES Foo(Value)

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" }
});
try
Expand Down Expand Up @@ -203,7 +200,6 @@ ParentId INT NULL

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" }
});
try
Expand Down Expand Up @@ -251,7 +247,6 @@ ParentId INT NULL

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" }
});
try
Expand Down Expand Up @@ -331,7 +326,6 @@ public async Task ShouldHandleComplexCycles()

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { "informix" }
});
try
Expand Down Expand Up @@ -383,7 +377,6 @@ public async Task ShouldExcludeSchemas()

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToExclude = new[] { user_1 }
});
try
Expand Down Expand Up @@ -427,7 +420,6 @@ public async Task ShouldIncludeSchemas()

var checkPoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Informix,
SchemasToInclude = new[] { user_2 }
});
try
Expand Down
10 changes: 0 additions & 10 deletions Respawn.DatabaseTests/MySqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public async Task ShouldDeleteData()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "MySqlTests" }
});
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -116,7 +115,6 @@ PRIMARY KEY (`BarValue`),

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "MySqlTests" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -142,7 +140,6 @@ public async Task ShouldHandleSelfRelationships()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "MySqlTests" }
});
try
Expand Down Expand Up @@ -181,7 +178,6 @@ public async Task ShouldHandleCircularRelationships()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "MySqlTests" }
});
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -226,7 +222,6 @@ public async Task ShouldHandleComplexCycles()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "MySqlTests" }
});
try
Expand Down Expand Up @@ -260,7 +255,6 @@ public async Task ShouldIgnoreTables()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
TablesToIgnore = new Table[] { "Foo" },
SchemasToInclude = new[] { "MySqlTests" }
});
Expand All @@ -283,7 +277,6 @@ public async Task ShouldIncludeTables()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
TablesToInclude = new Table[] { "Foo" },
SchemasToInclude = new[] { "MySqlTests" }
});
Expand Down Expand Up @@ -313,7 +306,6 @@ public async Task ShouldExcludeSchemas()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToExclude = new[] { "A", "MySqlTests" }
});
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -342,7 +334,6 @@ public async Task ShouldIncludeSchemas()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
SchemasToInclude = new[] { "B" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -361,7 +352,6 @@ public async Task ShouldResetSequencesAndIdentities()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.MySql,
WithReseed = true
});

Expand Down
13 changes: 0 additions & 13 deletions Respawn.DatabaseTests/OracleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public async Task ShouldDeleteData()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser }
});
try
Expand Down Expand Up @@ -87,7 +86,6 @@ public async Task ShouldDeleteMultipleTables()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
});
await respawner.ResetAsync(_connection);
Expand All @@ -113,7 +111,6 @@ public async Task ShouldHandleRelationships()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
});
try
Expand Down Expand Up @@ -147,7 +144,6 @@ public async Task ShouldHandleRelationshipsWithTableNames()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
TablesToInclude = new[] { new Table(_createdUser, "foo"), new Table(_createdUser, "baz") },
TablesToIgnore = new[] { new Table(_createdUser, "bar") }
Expand Down Expand Up @@ -193,7 +189,6 @@ public async Task ShouldHandleRelationshipsWithNamedPrimaryKeyConstraint()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { userA },
});
try
Expand Down Expand Up @@ -251,7 +246,6 @@ public async Task ShouldHandleComplexCycles()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
});
try
Expand Down Expand Up @@ -294,7 +288,6 @@ public async Task ShouldHandleCircularRelationships()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
});
try
Expand Down Expand Up @@ -325,7 +318,6 @@ public async Task ShouldIgnoreTables()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
TablesToIgnore = new[] { new Table("foo") }
});
Expand All @@ -349,7 +341,6 @@ public async Task ShouldIgnoreTablesWithSchema()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
TablesToIgnore = new[] { new Table(_createdUser, "foo") }
});
Expand All @@ -373,7 +364,6 @@ public async Task ShouldIncludeTables()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { _createdUser },
TablesToInclude = new[] { new Table("foo") }
});
Expand All @@ -397,7 +387,6 @@ public async Task ShouldIncludeTablesWithSchema()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
TablesToInclude = new[] { new Table(_createdUser, "foo") }
});
await respawner.ResetAsync(_connection);
Expand Down Expand Up @@ -425,7 +414,6 @@ public async Task ShouldExcludeSchemas()
var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
// We must make sure we don't delete all these users that are used by Oracle
DbAdapter = DbAdapter.Oracle,
SchemasToExclude = new[]
{
userA, "ANONYMOUS", "APEX_040000", "APEX_PUBLIC_USER", "APPQOSSYS",
Expand Down Expand Up @@ -463,7 +451,6 @@ public async Task ShouldIncludeSchemas()

var respawner = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Oracle,
SchemasToInclude = new[] { userB }
});
await respawner.ResetAsync(_connection);
Expand Down
28 changes: 4 additions & 24 deletions Respawn.DatabaseTests/PostgresTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ public async Task ShouldDeleteData()

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM \"foo\"").ShouldBe(100);

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres
});
var checkpoint = await Respawner.CreateAsync(_connection);
await checkpoint.ResetAsync(_connection);

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM \"foo\"").ShouldBe(0);
Expand All @@ -88,7 +85,6 @@ public async Task ShouldIgnoreTables()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToIgnore = new Table[] { "foo" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -112,7 +108,6 @@ public async Task ShouldIgnoreTablesIfSchemaSpecified()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToIgnore = new Table[] { new Table("eggs", "foo") }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -135,7 +130,6 @@ public async Task ShouldIncludeTables()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToInclude = new Table[] { "foo" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -159,7 +153,6 @@ public async Task ShouldIncludeTablesIfSchemaSpecified()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
TablesToInclude = new Table[] { new Table("eggs", "foo") }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -185,7 +178,6 @@ public async Task ShouldHandleRelationships()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
SchemasToInclude = new [] { "public" }
});
try
Expand Down Expand Up @@ -222,10 +214,7 @@ public async Task ShouldHandleCircularRelationships()
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM parent").ShouldBe(100);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM child").ShouldBe(100);

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres
});
var checkpoint = await Respawner.CreateAsync(_connection);
try
{
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -254,10 +243,7 @@ public async Task ShouldHandleSelfRelationships()

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM foo").ShouldBe(100);

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres
});
var checkpoint = await Respawner.CreateAsync(_connection);
try
{
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -305,10 +291,7 @@ public async Task ShouldHandleComplexCycles()
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM e").ShouldBe(1);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM f").ShouldBe(1);

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres
});
var checkpoint = await Respawner.CreateAsync(_connection);
try
{
await checkpoint.ResetAsync(_connection);
Expand Down Expand Up @@ -344,7 +327,6 @@ public async Task ShouldExcludeSchemas()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
SchemasToExclude = new [] { "a" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -369,7 +351,6 @@ public async Task ShouldIncludeSchemas()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
SchemasToInclude = new [] { "b" }
});
await checkpoint.ResetAsync(_connection);
Expand All @@ -388,7 +369,6 @@ public async Task ShouldResetSequencesAndIdentities()

var checkpoint = await Respawner.CreateAsync(_connection, new RespawnerOptions
{
DbAdapter = DbAdapter.Postgres,
WithReseed = true
});

Expand Down
Loading