Skip to content

Commit 7854f0f

Browse files
authored
Merge pull request #434 from DataObjects-NET/master-packages-update
Nuget packages updated
2 parents 090095b + 6c36792 commit 7854f0f

File tree

77 files changed

+4098
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4098
-593
lines changed

ChangeLog/7.2.0-Beta-2-dev.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44
[main] Obsolete SqlPersistTask constructors removed
55
[main] Obsolete AggregateProvider constructor removed
66
[main] Obsolete CalculateProvider constructor removed
7+
[main] Updated BitFaster.Caching to version 2.5.3
8+
[firebird] Updated client library to version 10.3.2
79
[mysql] SqlDml.NullIf function now correctly translated
810
[mysql] Improved support for string.PadLeft/PadRight opertaions
11+
[mysql] Updated client library to version 8.4.0
12+
[postgresql] Updated client library to version 8.0.6
13+
[postgresql] Improved .Milliseconds part translation for types that have the part
14+
[postgresql] Improved TimeSpan.TotalMilliseconds translation
15+
[postgresql] AppContext switch "Npgsql.EnableLegacyTimestampBehavior" is turned off if user hasn't set it before Domain build
16+
[postgresql] Both states of "Npgsql.EnableLegacyTimestampBehavior" AppContext switch are supported
17+
[postgresql] AppContext switch "Npgsql.DisableDateTimeInfinityConversions" is turned on if user hasn't set it before Domain build
18+
[postgresql] Supported both states of "Npgsql.DisableDateTimeInfinityConversions" AppContext switch, though "true" is recommended
19+
[postgresql] When infinity conversions are enabled, extra statements will be applied to certain operations to return expected results
20+
[postgresql] DateTime values '0001.01.01 00:00:00.00000' and '9999.12.31 23:59:59.99999' will be read as MinValue and MaxValue accordingly
21+
[postgresql] DateTimeOffset values '0001.01.01 00:00:00.00000+00:00' and '9999.12.31 23:59:59.99999+00:00' will be read as MinValue and MaxValue accordingly
22+
[postgresql] When legacy timestamp behavior is disabled, connection time zone is applied to DateTimeOffset values if possible, otherwise, to local one
23+
[postgresql] TimeSpans based on values lower than -9223372036854775800L and higher 92233720368547758xxL will be read as MinValue and MaxValue accordingly
24+
[oracle] Updated client library to version 23.7.0
925
[sqlite] Fixed string.Lenght translation
10-
[sqlite] Added support for string.PadLeft/PadRight operations
26+
[sqlite] Added support for string.PadLeft/PadRight operations
27+
[sqlserver] Updated client library to version 5.2.2

Extensions/Xtensive.Orm.Logging.NLog/Xtensive.Orm.Logging.NLog.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
1717
</PropertyGroup>
1818
<ItemGroup>
19-
<PackageReference Include="NLog" Version="4.5.0" />
19+
<PackageReference Include="NLog" Version="5.3.4" />
2020
</ItemGroup>
2121
<ItemGroup>
2222
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />

Extensions/Xtensive.Orm.Logging.log4net/Xtensive.Orm.Logging.log4net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
1717
</PropertyGroup>
1818
<ItemGroup>
19-
<PackageReference Include="log4net" Version="2.0.10" />
19+
<PackageReference Include="log4net" Version="3.0.3" />
2020
</ItemGroup>
2121
<ItemGroup>
2222
<ProjectReference Include="..\..\Orm\Xtensive.Orm\Xtensive.Orm.csproj" />

Orm/Xtensive.Orm.Firebird/Xtensive.Orm.Firebird.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</Content>
2626
</ItemGroup>
2727
<ItemGroup>
28-
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="8.5.3" />
28+
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="10.3.2" />
2929
</ItemGroup>
3030
<ItemGroup>
3131
<ProjectReference Include="..\Xtensive.Orm\Xtensive.Orm.csproj" />

Orm/Xtensive.Orm.MySql/Xtensive.Orm.MySql.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</EmbeddedResource>
4040
</ItemGroup>
4141
<ItemGroup>
42-
<PackageReference Include="MySql.Data" Version="8.0.31" />
42+
<PackageReference Include="MySql.Data" Version="8.4.0" />
4343
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
4444
</ItemGroup>
4545
<ItemGroup>

Orm/Xtensive.Orm.Oracle/Xtensive.Orm.Oracle.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</Content>
2626
</ItemGroup>
2727
<ItemGroup>
28-
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.18.151" />
28+
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" />
2929
</ItemGroup>
3030
<ItemGroup>
3131
<ProjectReference Include="..\Xtensive.Orm\Xtensive.Orm.csproj" />

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/Connection.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2009-2021 Xtensive LLC.
1+
// Copyright (C) 2009-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
@@ -10,6 +10,8 @@
1010
using System.Data.Common;
1111
using System.Threading;
1212
using System.Threading.Tasks;
13+
using System.Reflection;
14+
using System;
1315

1416
namespace Xtensive.Sql.Drivers.PostgreSql
1517
{
@@ -50,14 +52,13 @@ public override void Commit()
5052
{
5153
EnsureIsNotDisposed();
5254
EnsureTransactionIsActive();
53-
5455
try {
55-
if (!IsTransactionCompleted()) {
56-
ActiveTransaction.Commit();
56+
if(!IsTransactionCompleted()) {
57+
activeTransaction.Commit();
5758
}
5859
}
5960
finally {
60-
ActiveTransaction.Dispose();
61+
activeTransaction.Dispose();
6162
ClearActiveTransaction();
6263
}
6364
}
@@ -68,11 +69,11 @@ public override async Task CommitAsync(CancellationToken token = default)
6869
EnsureTransactionIsActive();
6970
try {
7071
if (!IsTransactionCompleted()) {
71-
await ActiveTransaction.CommitAsync(token).ConfigureAwait(false);
72+
await activeTransaction.CommitAsync(token).ConfigureAwait(false);
7273
}
7374
}
7475
finally {
75-
await ActiveTransaction.DisposeAsync().ConfigureAwait(false);
76+
await activeTransaction.DisposeAsync().ConfigureAwait(false);
7677
ClearActiveTransaction();
7778
}
7879
}
@@ -81,14 +82,13 @@ public override void Rollback()
8182
{
8283
EnsureIsNotDisposed();
8384
EnsureTransactionIsActive();
84-
8585
try {
8686
if (!IsTransactionCompleted()) {
87-
ActiveTransaction.Rollback();
87+
activeTransaction.Rollback();
8888
}
8989
}
9090
finally {
91-
ActiveTransaction.Dispose();
91+
activeTransaction.Dispose();
9292
ClearActiveTransaction();
9393
}
9494
}
@@ -99,11 +99,11 @@ public override async Task RollbackAsync(CancellationToken token = default)
9999
EnsureTransactionIsActive();
100100
try {
101101
if (!IsTransactionCompleted()) {
102-
await ActiveTransaction.RollbackAsync(token).ConfigureAwait(false);
102+
await activeTransaction.RollbackAsync(token).ConfigureAwait(false);
103103
}
104104
}
105105
finally {
106-
await ActiveTransaction.DisposeAsync().ConfigureAwait(false);
106+
await activeTransaction.DisposeAsync().ConfigureAwait(false);
107107
ClearActiveTransaction();
108108
}
109109
}
@@ -169,7 +169,7 @@ private void ExecuteNonQuery(string commandText)
169169
EnsureTransactionIsActive();
170170

171171
using var command = CreateCommand(commandText);
172-
command.ExecuteNonQuery();
172+
_ = command.ExecuteNonQuery();
173173
}
174174

175175
private async Task ExecuteNonQueryAsync(string commandText, CancellationToken token)
@@ -179,14 +179,11 @@ private async Task ExecuteNonQueryAsync(string commandText, CancellationToken to
179179

180180
var command = CreateCommand(commandText);
181181
await using (command.ConfigureAwait(false)) {
182-
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
182+
_ = await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
183183
}
184184
}
185185

186-
private bool IsTransactionCompleted()
187-
{
188-
return activeTransaction != null && activeTransaction.IsCompleted;
189-
}
186+
private bool IsTransactionCompleted() => activeTransaction.Connection == null;
190187

191188
// Constructors
192189

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/Driver.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ namespace Xtensive.Sql.Drivers.PostgreSql
1313
{
1414
internal abstract class Driver : SqlDriver
1515
{
16+
/// <summary>
17+
/// PosgreSQL-specific information about server.
18+
/// </summary>
19+
internal PostgreServerInfo PostgreServerInfo { get; }
20+
1621
[SecuritySafeCritical]
1722
protected override SqlConnection DoCreateConnection()
1823
{
@@ -95,14 +100,18 @@ private SqlExceptionType ProcessClientSideException(NpgsqlException clientSideEx
95100
}
96101
}
97102
}
103+
if (innerException is TimeoutException timeoutException) {
104+
return SqlExceptionType.OperationTimeout;
105+
}
98106
return SqlExceptionType.Unknown;
99107
}
100108

101109
// Constructors
102110

103-
protected Driver(CoreServerInfo coreServerInfo)
111+
protected Driver(CoreServerInfo coreServerInfo, PostgreServerInfo pgServerInfo)
104112
: base(coreServerInfo)
105113
{
114+
PostgreServerInfo = pgServerInfo;
106115
}
107116
}
108117
}

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2009-2021 Xtensive LLC.
1+
// Copyright (C) 2009-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
@@ -23,6 +23,9 @@ public class DriverFactory : SqlDriverFactory
2323
{
2424
private const string DatabaseAndSchemaQuery = "select current_database(), current_schema()";
2525

26+
private readonly static bool InfinityAliasForDatesEnabled;
27+
private readonly static bool LegacyTimestamptBehaviorEnabled;
28+
2629
/// <inheritdoc/>
2730
[SecuritySafeCritical]
2831
protected override string BuildConnectionString(UrlInfo url)
@@ -44,9 +47,6 @@ protected override string BuildConnectionString(UrlInfo url)
4447
builder.Username = url.User;
4548
builder.Password = url.Password;
4649
}
47-
else {
48-
builder.IntegratedSecurity = true;
49-
}
5050

5151
// custom options
5252
foreach (var param in url.Params) {
@@ -67,13 +67,18 @@ protected override SqlDriver CreateDriver(string connectionString, SqlDriverConf
6767
OpenConnectionFast(connection, configuration, false).GetAwaiter().GetResult();
6868
var version = GetVersion(configuration, connection);
6969
var defaultSchema = GetDefaultSchema(connection);
70-
return CreateDriverInstance(connectionString, version, defaultSchema);
70+
var defaultTimeZoneInfo = PostgreSqlHelper.GetTimeZoneInfoForServerTimeZone(connection.Timezone);
71+
return CreateDriverInstance(connectionString, version, defaultSchema, defaultTimeZoneInfo);
7172
}
7273

7374
/// <inheritdoc/>
7475
protected override async Task<SqlDriver> CreateDriverAsync(
7576
string connectionString, SqlDriverConfiguration configuration, CancellationToken token)
7677
{
78+
// these settings needed to be read before any connection happens
79+
var useInfinityAliasForDateTime = InfinityAliasForDatesEnabled;
80+
var legacyTimestampBehavior = LegacyTimestamptBehaviorEnabled;
81+
7782
var connection = new NpgsqlConnection(connectionString);
7883
await using (connection.ConfigureAwait(false)) {
7984
if (configuration.DbConnectionAccessors.Count > 0)
@@ -82,7 +87,8 @@ protected override async Task<SqlDriver> CreateDriverAsync(
8287
await OpenConnectionFast(connection, configuration, true, token).ConfigureAwait(false);
8388
var version = GetVersion(configuration, connection);
8489
var defaultSchema = await GetDefaultSchemaAsync(connection, token: token).ConfigureAwait(false);
85-
return CreateDriverInstance(connectionString, version, defaultSchema);
90+
var defaultTimeZoneInfo = PostgreSqlHelper.GetTimeZoneInfoForServerTimeZone(connection.Timezone);
91+
return CreateDriverInstance(connectionString, version, defaultSchema, defaultTimeZoneInfo);
8692
}
8793
}
8894

@@ -95,7 +101,8 @@ private static Version GetVersion(SqlDriverConfiguration configuration, NpgsqlCo
95101
}
96102

97103
private static SqlDriver CreateDriverInstance(
98-
string connectionString, Version version, DefaultSchemaInfo defaultSchema)
104+
string connectionString, Version version, DefaultSchemaInfo defaultSchema,
105+
TimeZoneInfo defaultTimeZone)
99106
{
100107
var coreServerInfo = new CoreServerInfo {
101108
ServerVersion = version,
@@ -105,20 +112,26 @@ private static SqlDriver CreateDriverInstance(
105112
DefaultSchemaName = defaultSchema.Schema,
106113
};
107114

115+
var pgsqlServerInfo = new PostgreServerInfo() {
116+
InfinityAliasForDatesEnabled = InfinityAliasForDatesEnabled,
117+
LegacyTimestampBehavior = LegacyTimestamptBehaviorEnabled,
118+
DefaultTimeZone = defaultTimeZone
119+
};
120+
108121
if (version.Major < 8 || (version.Major == 8 && version.Minor < 3)) {
109122
throw new NotSupportedException(Strings.ExPostgreSqlBelow83IsNotSupported);
110123
}
111124

112125
// We support 8.3, 8.4 and any 9.0+
113126

114127
return version.Major switch {
115-
8 when version.Minor == 3 => new v8_3.Driver(coreServerInfo),
116-
8 when version.Minor > 3 => new v8_4.Driver(coreServerInfo),
117-
9 when version.Minor == 0 => new v9_0.Driver(coreServerInfo),
118-
9 when version.Minor > 0 => new v9_1.Driver(coreServerInfo),
119-
10 => new v10_0.Driver(coreServerInfo),
120-
11 => new v10_0.Driver(coreServerInfo),
121-
_ => new v12_0.Driver(coreServerInfo)
128+
8 when version.Minor == 3 => new v8_3.Driver(coreServerInfo, pgsqlServerInfo),
129+
8 when version.Minor > 3 => new v8_4.Driver(coreServerInfo, pgsqlServerInfo),
130+
9 when version.Minor == 0 => new v9_0.Driver(coreServerInfo, pgsqlServerInfo),
131+
9 when version.Minor > 0 => new v9_1.Driver(coreServerInfo, pgsqlServerInfo),
132+
10 => new v10_0.Driver(coreServerInfo, pgsqlServerInfo),
133+
11 => new v10_0.Driver(coreServerInfo, pgsqlServerInfo),
134+
_ => new v12_0.Driver(coreServerInfo, pgsqlServerInfo)
122135
};
123136
}
124137

@@ -188,5 +201,58 @@ await SqlHelper.NotifyConnectionInitializingAsync(accessors,
188201
}
189202
}
190203
}
204+
205+
#region Helpers
206+
207+
private static bool SetOrGetExistingDisableInfinityAliasForDatesSwitch(bool valueToSet) =>
208+
GetSwitchValueOrSet(Orm.PostgreSql.WellKnown.DateTimeToInfinityConversionSwitchName, valueToSet);
209+
210+
private static bool SetOrGetExistingLegacyTimeStampBehaviorSwitch(bool valueToSet) =>
211+
GetSwitchValueOrSet(Orm.PostgreSql.WellKnown.LegacyTimestampBehaviorSwitchName, valueToSet);
212+
213+
private static bool GetSwitchValueOrSet(string switchName, bool valueToSet)
214+
{
215+
if (!AppContext.TryGetSwitch(switchName, out var currentValue)) {
216+
AppContext.SetSwitch(switchName, valueToSet);
217+
return valueToSet;
218+
}
219+
else {
220+
return currentValue;
221+
}
222+
}
223+
224+
#endregion
225+
226+
static DriverFactory()
227+
{
228+
// Starging from Npgsql 6.0 they broke compatibility by forcefully replacing
229+
// DateTime.MinValue/MaxValue of parameters with -Infinity and Infinity values.
230+
// This new "feature", though doesn't affect reading/writing of values and equality/inequality
231+
// filters, breaks some of operations such as parts extraction, default values for columns
232+
// (which are constants and declared on high levels of abstraction) and some others.
233+
234+
// We turn it off to make current code work as before and make current data of
235+
// the user be compatible with algorighms as long as possible.
236+
// But if the user sets the switch then we work with what we have.
237+
// Usage of such aliases makes us to create extra statements in SQL queries to provide
238+
// the same results the queries which are already written, which may make queries a bit slower.
239+
240+
// DO NOT REPLACE method call with constant value when debugging, CHANGE THE PARAMETER VALUE.
241+
InfinityAliasForDatesEnabled = !SetOrGetExistingDisableInfinityAliasForDatesSwitch(valueToSet: true);
242+
243+
// Legacy timestamp behavoir turns off certain parameter value binding requirements
244+
// and makes Npgsql work like v4 or older.
245+
// Current behavior require manual specification of unspecified kind for DateTime values,
246+
// because Local or Utc kind now meand that underlying type of value to Timestamp without time zone
247+
// and Timestamp with time zone respectively.
248+
// It also affects DateTimeOffsets, now there is a requirement to move timezone of value to Utc
249+
// this forces us to use only local timezone when reading values, which basically ignores
250+
// Postgre's setting SET TIME ZONE for database session.
251+
252+
// We have to use current mode, not the legacy one, because there is a chance of legacy mode elimination.
253+
254+
// DO NOT REPLACE method call with constant value when debugging, CHANGE THE PARAMETER VALUE.
255+
LegacyTimestamptBehaviorEnabled = SetOrGetExistingLegacyTimeStampBehaviorSwitch(valueToSet: false);
256+
}
191257
}
192258
}

0 commit comments

Comments
 (0)