Skip to content

Merge upstream #379

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

Merged
merged 65 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2e4af97
Remove obsoletes that were marked in 7.1 or older versions
alex-kulakov Jan 28, 2025
f968006
Update BitFaster.Caching to version 2.5.3
alex-kulakov Jan 28, 2025
f6f7864
Update Firebird client package to version 10.3.2
alex-kulakov Jan 28, 2025
78ff9d7
Update log4net package to version 3.0.3
alex-kulakov Jan 28, 2025
8eb7842
Update NLog package to version 5.3.4
alex-kulakov Jan 28, 2025
5dbcfde
Update Ms SQL Server client library to version 5.2.2
alex-kulakov Jan 28, 2025
09a4a9d
Update Oracle client library to version 23.7.0
alex-kulakov Jan 28, 2025
6e1ede4
Update MySQL client library to version 8.4.0
alex-kulakov Jan 30, 2025
9a7b5ff
Update Postgresql client library package to version 6.0.13
alex-kulakov Feb 17, 2025
74bc666
SqlExtract: Remove commented code
alex-kulakov Feb 17, 2025
49129f0
Postgre drivers: Add extra provider specific info to driver
alex-kulakov Feb 17, 2025
ac30a98
Paths and Polygon types are fixed now and no longer throw NRE on gett…
alex-kulakov Feb 17, 2025
180425e
Sql level tests for new behavior of Npgsql
alex-kulakov Feb 17, 2025
3b35b2c
Tests for operations over Min/Max values of DateOnly/DateTime/DateTim…
alex-kulakov Feb 17, 2025
b77aa48
Required changes for type mapper for correct reading writing values
alex-kulakov Feb 17, 2025
bbd4a59
PostgreSql connection: access internal property to keep functionality
alex-kulakov Feb 17, 2025
a6e8ed3
Add support for infinity/-infinity replacement within Npgsql
alex-kulakov Feb 17, 2025
446a8a2
Another Npgsql exception detected as operation timeout
alex-kulakov Feb 18, 2025
8ab8c8b
Update Postgresql client library package to version 8.0.6
alex-kulakov Feb 18, 2025
06391a9
Pgsql connection: IsCompleted now can be replace with tx.Connection==…
alex-kulakov Feb 19, 2025
33c22e4
Connection implementations: direct access to activeTransaction property
alex-kulakov Feb 19, 2025
2751df6
Init AppContext switches before any tests
alex-kulakov Feb 20, 2025
9d75199
No explicit tests because of AppContext
alex-kulakov Feb 20, 2025
f0b9e1a
PostgreSQL TypeMapper: assign real Min/Max values instead of server v…
alex-kulakov Feb 24, 2025
8180757
Remove unnecessary parameter SqlNodeCloneContext ctor
alex-kulakov Feb 24, 2025
4fba084
Improved InfinityAliasTests
alex-kulakov Feb 24, 2025
e88b982
Linq Dates operations tests improved
alex-kulakov Feb 24, 2025
8fcc534
PostgreSql: Apply connection timezone to datetimeoffset values on rea…
alex-kulakov Feb 27, 2025
f7edd11
Tests improved
alex-kulakov Feb 27, 2025
b9f3956
StorageProviderVersion extended + TestConfiguration better names
alex-kulakov Feb 27, 2025
57ee1a5
Fixed mismatch of +/-Infinity replacements when part extracted
alex-kulakov Feb 27, 2025
fe73869
Postgre: Native support of reading/binding DateOnly values
alex-kulakov Feb 27, 2025
daffaad
Improved checks for min/max values
alex-kulakov Feb 27, 2025
4d349c3
InfinityAliasTest: Handles extraction non-Year part from infinity value
alex-kulakov Mar 3, 2025
2519969
Postgresql TypeMapper changes
alex-kulakov Mar 3, 2025
b62b2e9
Postgresql compiler changes
alex-kulakov Mar 4, 2025
df67eac
Add IntervalToMilliseconds test
alex-kulakov Mar 4, 2025
aeae65a
Correct fields place
alex-kulakov Mar 4, 2025
2617841
Handle change of result type of Extract in Posgre for TotalMilliseconds
alex-kulakov Mar 6, 2025
540a9c5
Optimize test values
alex-kulakov Mar 6, 2025
b9a1654
PostgreSqlHelper: Change getting timezone
alex-kulakov Apr 21, 2025
a228af6
PostgreSql: TimeZoneInfo as DefaultTimeZone
alex-kulakov Apr 21, 2025
30c151d
Output timezone when test failed
alex-kulakov Apr 22, 2025
b2d70fc
PostgreSqlHelperTest : better split to resolvable and unresolvable zo…
alex-kulakov Apr 22, 2025
80dd482
Improve changelog
alex-kulakov Apr 22, 2025
d6f5159
Merge branch 'master' into master-packages-update
alex-kulakov Apr 22, 2025
770a7c7
Fix error after merge
alex-kulakov Apr 23, 2025
e6b0ee3
Exclude not PostgreSql providers from using MinMaxXXXEntity
alex-kulakov Apr 23, 2025
b9a912b
Temporary revert SQLite client library change
alex-kulakov Apr 24, 2025
1b70d5d
Revert SQLite client package downgrade
alex-kulakov Apr 24, 2025
0901e6c
Merge branch 'master' into master-remove-obsoletes
alex-kulakov Apr 24, 2025
aeaa8d3
Improve changelog
alex-kulakov Apr 24, 2025
090095b
Merge pull request #433 from DataObjects-NET/master-remove-obsoletes
alex-kulakov Apr 24, 2025
6c36792
Merge branch 'master' into master-packages-update
alex-kulakov Apr 24, 2025
7854f0f
Merge pull request #434 from DataObjects-NET/master-packages-update
alex-kulakov Apr 24, 2025
c30cb88
Use Npgsql 9.0.3
alex-kulakov Apr 25, 2025
f1f9984
Apply native 'trim_scale' function to aggregates results
alex-kulakov Apr 26, 2025
31e149b
Improve changelog
alex-kulakov Apr 26, 2025
9607397
Merge pull request #435 from DataObjects-NET/master-pg-trimscale
alex-kulakov Apr 26, 2025
49f46db
Improve changelog
alex-kulakov Apr 26, 2025
c4ff4ed
Merge pull request #437 from DataObjects-NET/master-latest-npgsql
alex-kulakov Apr 26, 2025
6f9c8ea
Bump version to 7.2.0-Beta-2
alex-kulakov Apr 26, 2025
3d1fbda
Change version
alex-kulakov Apr 27, 2025
98ffca7
Create changlog file
alex-kulakov Apr 27, 2025
d743cb4
Merge remote-tracking branch 'upstream/master' into mergeUpstream
SergeiPavlov Apr 28, 2025
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
6 changes: 0 additions & 6 deletions ChangeLog/7.2.0-Beta-2-dev.txt

This file was deleted.

28 changes: 28 additions & 0 deletions ChangeLog/7.2.0-Beta-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[main] Upgrade hints change names of constructors' string parameters for better understanding of what suppose to be in them.
[main] Improved string operations Trim/TrimStart/TrimEnd support
[main] Obsolete DomainConfiguration.DefauktForeignKeyMode const removed, the correctly named constant still exists
[main] Obsolete SqlPersistTask constructors removed
[main] Obsolete AggregateProvider constructor removed
[main] Obsolete CalculateProvider constructor removed
[main] Updated BitFaster.Caching to version 2.5.3
[firebird] Updated client library to version 10.3.2
[mysql] SqlDml.NullIf function now correctly translated
[mysql] Improved support for string.PadLeft/PadRight opertaions
[mysql] Updated client library to version 8.4.0
[postgresql] Updated client library to version 9.0.3
[postgresql] Improved .Milliseconds part translation for types that have the part
[postgresql] Improved TimeSpan.TotalMilliseconds translation
[postgresql] AppContext switch "Npgsql.EnableLegacyTimestampBehavior" is turned off if user hasn't set it before Domain build
[postgresql] Both states of "Npgsql.EnableLegacyTimestampBehavior" AppContext switch are supported
[postgresql] AppContext switch "Npgsql.DisableDateTimeInfinityConversions" is turned on if user hasn't set it before Domain build
[postgresql] Supported both states of "Npgsql.DisableDateTimeInfinityConversions" AppContext switch, though "true" is recommended
[postgresql] When infinity conversions are enabled, extra statements will be applied to certain operations to return expected results
[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
[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
[postgresql] When legacy timestamp behavior is disabled, connection time zone is applied to DateTimeOffset values if possible, otherwise, to local one
[postgresql] TimeSpans based on values lower than -9223372036854775800L and higher 92233720368547758xxL will be read as MinValue and MaxValue accordingly
[postgresql] For PostgreSQL 13+ apply 'trim_scale' function to results of aggregation to improve compatibility with .NET decimal
[oracle] Updated client library to version 23.7.0
[sqlite] Fixed string.Lenght translation
[sqlite] Added support for string.PadLeft/PadRight operations
[sqlserver] Updated client library to version 5.2.2
Empty file added ChangeLog/7.2.0-RC-dev.txt
Empty file.
12 changes: 6 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
<PackageVersion Include="BitFaster.Caching" Version="2.5.3" />
<PackageVersion Include="FirebirdSql.Data.FirebirdClient" Version="8.5.3" />
<PackageVersion Include="FirebirdSql.Data.FirebirdClient" Version="10.3.2" />
<PackageVersion Include="FSharp.Core" Version="4.7.0" />
<PackageVersion Include="Google.Protobuf" Version="3.29.3" />
<PackageVersion Include="log4net" Version="2.0.10" />
<PackageVersion Include="log4net" Version="3.0.3" />
<PackageVersion Include="Mono.Cecil" Version="0.11.6" />
<PackageVersion Include="MySql.Data" Version="8.0.31" />
<PackageVersion Include="NLog" Version="4.5.0" />
<PackageVersion Include="Npgsql" Version="8.0.3" />
<PackageVersion Include="MySql.Data" Version="8.4.0" />
<PackageVersion Include="NLog" Version="5.3.4" />
<PackageVersion Include="Npgsql" Version="9.0.3" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="2.18.151" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2008-2020 Xtensive LLC.
// Copyright (C) 2008-2025 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Alexey Gamzov
Expand All @@ -18,15 +18,24 @@ namespace Xtensive.Orm.Providers.PostgreSql
/// </summary>
public class DomainHandler : Providers.DomainHandler
{
/// <summary>
/// <see langword="true"/> if storage can trim insignificant zeros in numeric values
/// </summary>
protected bool HasNativeTrimOfInsignificantZerosInDecimals =>
Handlers.ProviderInfo.StorageVersion.Major >= 13;

/// <inheritdoc/>
protected override ICompiler CreateCompiler(CompilerConfiguration configuration) =>
new SqlCompiler(Handlers, configuration);

/// <inheritdoc/>
protected override IPreCompiler CreatePreCompiler(CompilerConfiguration configuration)
{
var decimalAggregateCorrector = new AggregateOverDecimalColumnCorrector(Handlers.Domain.Model);
return new CompositePreCompiler(decimalAggregateCorrector, base.CreatePreCompiler(configuration));
if (!HasNativeTrimOfInsignificantZerosInDecimals) {
var decimalAggregateCorrector = new AggregateOverDecimalColumnCorrector(Handlers.Domain.Model);
return new CompositePreCompiler(decimalAggregateCorrector, base.CreatePreCompiler(configuration));
}
return base.CreatePreCompiler(configuration);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (C) 2014-2020 Xtensive LLC.
// Copyright (C) 2014-2025 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Alena Mikshina
// Created: 2014.05.06;

using System;
using Xtensive.Core;
using Xtensive.Sql;
using Xtensive.Sql.Dml;

namespace Xtensive.Orm.Providers.PostgreSql
Expand All @@ -17,6 +18,15 @@ namespace Xtensive.Orm.Providers.PostgreSql
/// </summary>
public class PostgresqlSqlDml
{
/// <summary>
/// Creates an expression for native "trim_scale" function call. The function is supported starting from PostgreSQL 13
/// </summary>
public static SqlExpression DecimalTrimScale(SqlExpression operand)
{
ArgumentNullException.ThrowIfNull(operand);
return SqlDml.FunctionCall("TRIM_SCALE", operand);
}

#region Spatial types

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2009-2021 Xtensive LLC.
// Copyright (C) 2009-2025 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Denis Krjuchkov
Expand All @@ -21,6 +21,8 @@ internal class SqlCompiler : Providers.SqlCompiler
{
private const int MaxDotnetDecimalPrecision = 28;

private readonly bool canRemoveInsignificantZerosInDecimals;

protected override SqlProvider VisitFreeText(FreeTextProvider provider)
{
var rankColumnName = provider.Header.Columns[provider.Header.Columns.Count - 1].Name;
Expand Down Expand Up @@ -61,6 +63,11 @@ protected override SqlExpression ProcessAggregate(SqlProvider source, IReadOnlyL
var aggregateType = aggregateColumn.AggregateType;
var originCalculateColumn = source.Origin.Header.Columns[aggregateColumn.SourceIndex];
if (AggregateRequiresDecimalAdjustments(aggregateColumn)) {
if (canRemoveInsignificantZerosInDecimals) {
return (IsCalculatedColumn(originCalculateColumn))
? PostgresqlSqlDml.DecimalTrimScale(SqlDml.Cast(result, Driver.MapValueType(aggregateColumn.Type)))
: PostgresqlSqlDml.DecimalTrimScale(result);
}
if (!IsCalculatedColumn(originCalculateColumn)) {
// this is aggregate by one column, result will be defined by the precision and scale of the column
return result;
Expand Down Expand Up @@ -138,6 +145,7 @@ AggregateType.Min or
public SqlCompiler(HandlerAccessor handlers, in CompilerConfiguration configuration)
: base(handlers, configuration)
{
canRemoveInsignificantZerosInDecimals = handlers.ProviderInfo.StorageVersion.Major >= 13;
}
}
}
32 changes: 14 additions & 18 deletions Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/Connection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2009-2021 Xtensive LLC.
// Copyright (C) 2009-2025 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
// Created by: Denis Krjuchkov
Expand All @@ -8,6 +8,7 @@
using Npgsql;
using System.Data;
using System.Data.Common;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xtensive.Core;
Expand Down Expand Up @@ -54,10 +55,9 @@ public override void Commit(bool rollbackOnFail = false)
{
EnsureIsNotDisposed();
EnsureTransactionIsActive();

try {
if (!IsTransactionCompleted()) {
ActiveTransaction.Commit();
if(!IsTransactionCompleted()) {
activeTransaction.Commit();
}
activeTransactionIsCompleted = true;
}
Expand All @@ -66,7 +66,7 @@ public override void Commit(bool rollbackOnFail = false)
throw;
}
finally {
ActiveTransaction.Dispose();
activeTransaction.Dispose();
ClearActiveTransaction();
}
}
Expand All @@ -77,7 +77,7 @@ public override async Task CommitAsync(bool rollbackOnFail = false, Cancellation
EnsureTransactionIsActive();
try {
if (!IsTransactionCompleted()) {
await ActiveTransaction.CommitAsync(token).ConfigureAwait(false);
await activeTransaction.CommitAsync(token).ConfigureAwait(false);
}
activeTransactionIsCompleted = true;
}
Expand All @@ -86,7 +86,7 @@ public override async Task CommitAsync(bool rollbackOnFail = false, Cancellation
throw;
}
finally {
await ActiveTransaction.DisposeAsync().ConfigureAwait(false);
await activeTransaction.DisposeAsync().ConfigureAwait(false);
ClearActiveTransaction();
}
}
Expand All @@ -95,14 +95,13 @@ public override void Rollback()
{
EnsureIsNotDisposed();
EnsureTransactionIsActive();

try {
if (!IsTransactionCompleted()) {
ActiveTransaction.Rollback();
activeTransaction.Rollback();
}
}
finally {
ActiveTransaction.Dispose();
activeTransaction.Dispose();
ClearActiveTransaction();
}
}
Expand All @@ -113,11 +112,11 @@ public override async Task RollbackAsync(CancellationToken token = default)
EnsureTransactionIsActive();
try {
if (!IsTransactionCompleted()) {
await ActiveTransaction.RollbackAsync(token).ConfigureAwait(false);
await activeTransaction.RollbackAsync(token).ConfigureAwait(false);
}
}
finally {
await ActiveTransaction.DisposeAsync().ConfigureAwait(false);
await activeTransaction.DisposeAsync().ConfigureAwait(false);
ClearActiveTransaction();
}
}
Expand Down Expand Up @@ -183,7 +182,7 @@ private void ExecuteNonQuery(string commandText)
EnsureTransactionIsActive();

using var command = CreateCommand(commandText);
command.ExecuteNonQuery();
_ = command.ExecuteNonQuery();
}

private async Task ExecuteNonQueryAsync(string commandText, CancellationToken token)
Expand All @@ -193,14 +192,11 @@ private async Task ExecuteNonQueryAsync(string commandText, CancellationToken to

var command = CreateCommand(commandText);
await using (command.ConfigureAwait(false)) {
await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
_ = await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
}
}

private bool IsTransactionCompleted()
{
return activeTransaction != null && activeTransactionIsCompleted;
}
private bool IsTransactionCompleted() => activeTransaction.Connection == null;

// Constructors

Expand Down
11 changes: 10 additions & 1 deletion Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ namespace Xtensive.Sql.Drivers.PostgreSql
{
internal abstract class Driver : SqlDriver
{
/// <summary>
/// PosgreSQL-specific information about server.
/// </summary>
internal PostgreServerInfo PostgreServerInfo { get; }

[SecuritySafeCritical]
protected override SqlConnection DoCreateConnection()
{
Expand Down Expand Up @@ -95,14 +100,18 @@ private SqlExceptionType ProcessClientSideException(NpgsqlException clientSideEx
}
}
}
if (innerException is TimeoutException timeoutException) {
return SqlExceptionType.OperationTimeout;
}
return SqlExceptionType.Unknown;
}

// Constructors

protected Driver(CoreServerInfo coreServerInfo)
protected Driver(CoreServerInfo coreServerInfo, PostgreServerInfo pgServerInfo)
: base(coreServerInfo)
{
PostgreServerInfo = pgServerInfo;
}
}
}
Loading