Skip to content

Commit 2169d2b

Browse files
committed
Merge branch 'scrocquesel-feat/npgsqldatasource' into release/6.0.0
2 parents d97055c + a161427 commit 2169d2b

14 files changed

+56
-100
lines changed

src/Directory.Build.props

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,4 @@
1010
<LangVersion>latest</LangVersion>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
</PropertyGroup>
13-
14-
<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">
15-
16-
<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
17-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
18-
19-
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
20-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
21-
22-
<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
23-
<DebugType>embedded</DebugType>
24-
25-
</PropertyGroup>
26-
2713
</Project>

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt renamed to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
1010
DB Operation: Dispose command
1111
Info: Creating the "schemaversions" table

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt renamed to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
1010
DB Operation: Dispose command
1111
Info: Creating the "test"."TestSchemaVersions" table

src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt renamed to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DB Operation: Open connection
22
Info: Beginning database upgrade
3-
Info: Checking whether journal table exists..
3+
Info: Checking whether journal table exists
44
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
55
DB Operation: Dispose command
66
Info: Journal table does not exist
77
Info: Executing Database Server script 'Script0001.sql'
8-
Info: Checking whether journal table exists..
8+
Info: Checking whether journal table exists
99
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
1010
DB Operation: Dispose command
1111
Info: Creating the "schemaversions" table

src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs renamed to src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs

File renamed without changes.

src/Tests/PostgresTableJournalTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ namespace DbUp.Postgresql.Tests;
1111

1212
public class PostgresTableJournalTests : IDisposable
1313
{
14-
[Fact]
14+
[Fact]
1515
public void uses_positional_parameters_when_sql_rewriting_disabled()
1616
{
1717
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", false);
1818

1919
var dbConnection = Substitute.For<IDbConnection>();
20-
var connectionManager = new TestConnectionManager(dbConnection, true);
20+
var connectionManager = new TestConnectionManager(dbConnection);
2121
var command = Substitute.For<IDbCommand>();
2222
var param1 = Substitute.For<IDbDataParameter>();
2323
var param2 = Substitute.For<IDbDataParameter>();
2424
dbConnection.CreateCommand().Returns(command);
2525
command.CreateParameter().Returns(param1, param2);
2626
command.ExecuteScalar().Returns(x => 0);
2727
var consoleUpgradeLog = new ConsoleUpgradeLog();
28-
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
28+
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
29+
"SchemaVersions");
2930

3031
// Act
3132
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -45,15 +46,16 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
4546
AppContext.SetSwitch("Npgsql.EnableSqlRewriting", true);
4647

4748
var dbConnection = Substitute.For<IDbConnection>();
48-
var connectionManager = new TestConnectionManager(dbConnection, true);
49+
var connectionManager = new TestConnectionManager(dbConnection);
4950
var command = Substitute.For<IDbCommand>();
5051
var param1 = Substitute.For<IDbDataParameter>();
5152
var param2 = Substitute.For<IDbDataParameter>();
5253
dbConnection.CreateCommand().Returns(command);
5354
command.CreateParameter().Returns(param1, param2);
5455
command.ExecuteScalar().Returns(x => 0);
5556
var consoleUpgradeLog = new ConsoleUpgradeLog();
56-
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public", "SchemaVersions");
57+
var journal = new PostgresqlTableJournal(() => connectionManager, () => consoleUpgradeLog, "public",
58+
"SchemaVersions");
5759

5860
// Act
5961
journal.StoreExecutedScript(new SqlScript("test", "select 1"), () => command);
@@ -62,7 +64,8 @@ public void uses_named_parameters_when_sql_rewriting_enabled()
6264
command.Received(2).CreateParameter();
6365
param1.ParameterName.ShouldBe("scriptName");
6466
param2.ParameterName.ShouldBe("applied");
65-
command.CommandText.ShouldBe("""insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
67+
command.CommandText.ShouldBe(
68+
"""insert into "public"."SchemaVersions" (ScriptName, Applied) values (@scriptName, @applied)""");
6669
command.Received().ExecuteNonQuery();
6770
}
6871

src/Tests/Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net462;net8</TargetFrameworks>
4+
<TargetFramework>net8</TargetFramework>
55
<AssemblyName>Tests</AssemblyName>
66
<RootNamespace>DbUp.Postgresql.Tests</RootNamespace>
7-
<!-- <ImplicitUsings>enable</ImplicitUsings> Can't use implict usings with net46 -->
7+
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
</PropertyGroup>
1010

1111
<ItemGroup>
1212
<ProjectReference Include="..\dbup-postgresql\dbup-postgresql.csproj"/>
13-
<PackageReference Include="DbUp.Tests.Common" Version="5.0.52-Split.8"/>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
15-
<PackageReference Include="xunit" Version="2.6.6"/>
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
13+
<PackageReference Include="DbUp.Tests.Common" Version="6.0.0-beta.146"/>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
15+
<PackageReference Include="xunit" Version="2.9.0"/>
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>

src/dbup-postgresql.sln.DotSettings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQ/@EntryIndexedValue">SQ</s:String>
66
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
77
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
8+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
9+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
10+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
811
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
912
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>

src/dbup-postgresql/PostgresqlConnectionManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public PostgresqlConnectionManager(string connectionString, X509Certificate2 cer
3939
{
4040
}
4141

42+
/// <summary>
43+
/// Creates a new PostgreSQL database connection with a NpgsqlDatasource
44+
/// </summary>
45+
/// <param name="datasource">The PostgreSQL NpgsqlDataSource.</param>
46+
public PostgresqlConnectionManager(NpgsqlDataSource datasource)
47+
: base(new DelegateConnectionFactory(l => datasource.CreateConnection()))
48+
{
49+
}
50+
4251
/// <summary>
4352
/// Splits the statements in the script using the ";" character.
4453
/// </summary>

0 commit comments

Comments
 (0)