diff --git a/.github/workflows/reusable-storage-dependant-tests.yml b/.github/workflows/reusable-storage-dependant-tests.yml index 689ec66da..86b2fcb18 100644 --- a/.github/workflows/reusable-storage-dependant-tests.yml +++ b/.github/workflows/reusable-storage-dependant-tests.yml @@ -16,7 +16,7 @@ on: target_framework: description: 'Target framework' required: true - default: 'net6.0' + default: 'net8.0' type: string specific_sha: description: 'Commit SHA to checkout' @@ -158,14 +158,6 @@ jobs: run: | docker stop $(docker ps -a -q) - - name: Temp log output - if: | - !cancelled() - run: | - echo "github event name: ${{ github.event_name }}" - echo "reproc step outcome: ${{ steps.reprocessing.outcome }}" - echo "complex step outcome: ${{ steps.complex_tests.outcome }}" - - name: Publish raw test results as files if: | (!cancelled() && inputs.publish_raw_results) || failure() diff --git a/.github/workflows/reusable-storage-independant-tests.yml b/.github/workflows/reusable-storage-independant-tests.yml index 822032cc8..3322cebd6 100644 --- a/.github/workflows/reusable-storage-independant-tests.yml +++ b/.github/workflows/reusable-storage-independant-tests.yml @@ -11,7 +11,7 @@ on: target_framework: description: 'Target framework' required: true - default: 'net6.0' + default: 'net8.0' type: string test_output_verbosity: description: 'Verbosity for dotnet test command' @@ -123,10 +123,9 @@ jobs: - name: Make Final Test report if: | - (github.event_name == 'push' && steps.complex_tests.outcome != 'cancelled') - || (github.event_name == 'pull_request' && steps.complex_tests.outcome != 'cancelled') - || (github.event_name == 'workflow_dispatch' && steps.complex_tests.outcome != 'cancelled') - || steps.complex_tests.outcome == 'failure' + !cancelled() + && ((github.event_name == 'push') || (github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch') + || (steps.reprocessing.outcome == 'failure' || steps.complex_tests.outcome == 'failure')) timeout-minutes: 1 uses: dorny/test-reporter@v2.1.1 with: diff --git a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs index 5559acb47..3903e2611 100644 --- a/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs +++ b/Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs @@ -23,6 +23,8 @@ public class DriverFactory : SqlDriverFactory { private const string DatabaseAndSchemaQuery = "select current_database(), current_schema()"; + private readonly static Guid InstanceIdentifier; + private readonly static bool InfinityAliasForDatesEnabled; private readonly static bool LegacyTimestamptBehaviorEnabled; @@ -225,8 +227,10 @@ private static bool GetSwitchValueOrSet(string switchName, bool valueToSet) static DriverFactory() { - // Starging from Npgsql 6.0 they broke compatibility by forcefully replacing - // DateTime.MinValue/MaxValue of parameters with -Infinity and Infinity values. + InstanceIdentifier = Guid.NewGuid(); + + // Starting from Npgsql 6.0 they broke compatibility by forcefully replacing + // DateTime.MinValue/MaxValue in parameters with -Infinity and Infinity values. // This new "feature", though doesn't affect reading/writing of values and equality/inequality // filters, breaks some of operations such as parts extraction, default values for columns // (which are constants and declared on high levels of abstraction) and some others. diff --git a/Orm/Xtensive.Orm.Tests.Sql/PostgreSql/InfinityAliasTest.cs b/Orm/Xtensive.Orm.Tests.Sql/PostgreSql/InfinityAliasTest.cs index a3a321719..dd768d1dd 100644 --- a/Orm/Xtensive.Orm.Tests.Sql/PostgreSql/InfinityAliasTest.cs +++ b/Orm/Xtensive.Orm.Tests.Sql/PostgreSql/InfinityAliasTest.cs @@ -29,6 +29,8 @@ public sealed class InfinityAliasTest : SqlTest private TypeMapping dateTimeTypeMapping; private TypeMapping dateTimeOffsetTypeMapping; + private TimeSpan localTimezone; + protected override void CheckRequirements() { Require.ProviderIs(StorageProvider.PostgreSql); @@ -39,6 +41,7 @@ protected override void TestFixtureSetUp() base.TestFixtureSetUp(); var localZone = DateTimeOffset.Now.ToLocalTime().Offset; + localTimezone = localZone; var localZoneString = ((localZone < TimeSpan.Zero) ? "-" : "+") + localZone.ToString(@"hh\:mm"); var initConnectionCommand = Connection.CreateCommand($"SET TIME ZONE INTERVAL '{localZoneString}' HOUR TO MINUTE"); _ = initConnectionCommand.ExecuteNonQuery(); @@ -466,10 +469,14 @@ private void TestMinDateTimeOffsetSelectDatePart(bool isOn) DateTimeOffset.MinValue.Day, isOn); - // timezone for DateTimeOffset.MinValue value in postgre is set to 04:02:33, at least when instance is in UTC+5 timezone + var serverSideHours = (localTimezone > TimeSpan.Zero) + ? localTimezone.Hours // positive zone + : (localTimezone < TimeSpan.Zero) + ? 23 + localTimezone.Hours // negative zone + : localTimezone.Hours; // UTC TestDateTimeOffsetPartExtraction(DateTimeOffsetMinValueTable, SqlDateTimeOffsetPart.Hour, - 5, - isOn ? DateTimeOffset.MinValue.Hour : 5, + serverSideHours, + serverSideHours, isOn); TestDateTimeOffsetPartExtraction(DateTimeOffsetMinValueTable, SqlDateTimeOffsetPart.Minute, DateTimeOffset.MinValue.Minute, @@ -546,27 +553,39 @@ public void DateTimeOffsetMaxSelectDatePartDateTest() private void TestMaxDateTimeOffsetSelectDatePart(bool isOn) { + var overflowHappens = localTimezone > TimeSpan.Zero; + // There is overflow of year because of PostgreSQL time zone functionality + var overflowYearValue = overflowHappens ? 1 : 0; TestDateTimeOffsetPartExtraction(DateTimeOffsetMaxValueTable, SqlDateTimeOffsetPart.Year, - DateTimeOffset.MaxValue.Year + 1, - (isOn) ? DateTimeOffset.MaxValue.Year : DateTimeOffset.MaxValue.Year + 1, + DateTimeOffset.MaxValue.Year + overflowYearValue, + DateTimeOffset.MaxValue.Year + overflowYearValue, isOn); // there is value overflow to 01 in case of no aliases + var serverSideMonths = (localTimezone > TimeSpan.Zero) ? 1 : 12; TestDateTimeOffsetPartExtraction(DateTimeOffsetMaxValueTable, SqlDateTimeOffsetPart.Month, - 1, - (isOn) ? DateTimeOffset.MaxValue.Month : 1, + serverSideMonths, + serverSideMonths, isOn); + // there is value overflow to 01 in case of no aliases + var serverSideDays = (localTimezone > TimeSpan.Zero) ? 1 : 31; TestDateTimeOffsetPartExtraction(DateTimeOffsetMaxValueTable, SqlDateTimeOffsetPart.Day, - 1, - (isOn) ? DateTimeOffset.MaxValue.Day : 1, + serverSideDays, + serverSideDays, isOn); // timezone for DateTimeOffset.MaxValue value in postgre is set to 04:59:59.999999, at least when instance is in UTC+5 timezone + var serverSideHours = (localTimezone > TimeSpan.Zero) + ? localTimezone.Hours - 1 // positive zone + : (localTimezone < TimeSpan.Zero) + ? 23 + localTimezone.Hours // negative zone + : 23; // UTC + TestDateTimeOffsetPartExtraction(DateTimeOffsetMaxValueTable, SqlDateTimeOffsetPart.Hour, - 4, - (isOn) ? DateTimeOffset.MaxValue.Hour : 4, + serverSideHours, + serverSideHours, isOn); TestDateTimeOffsetPartExtraction(DateTimeOffsetMaxValueTable, SqlDateTimeOffsetPart.Minute, DateTimeOffset.MaxValue.Minute, @@ -587,22 +606,26 @@ private void TestDatePartExtraction(string table, SqlDatePart part, int expected using (var reader = command.ExecuteReader()) { while (reader.Read()) { - if (aliasesEnabled && part != SqlDatePart.Year) { - // year from +-infinity -> +-infinity + if (aliasesEnabled) { + // +-infinify + // year from +-infinity -> +-infinity (or 0 in case of versions older than 9.6) // month from +-infinity -> null (or 0 in case of versions older that 9.6) if (Driver.CoreServerInfo.ServerVersion >= StorageProviderVersion.PostgreSql96) { - Assert.That(reader.IsDBNull(0)); + if (part != SqlDatePart.Year) { + Assert.That(reader.IsDBNull(0)); + } + else { + var partValue = reader.GetDouble(0); + Assert.That(double.IsInfinity(partValue), Is.True); + } } else { var partValue = reader.GetDouble(0); Assert.That(partValue, Is.Zero); } } - if (Driver.CoreServerInfo.ServerVersion < StorageProviderVersion.PostgreSql96) { - var partValue = reader.GetDouble(0); - Assert.That(partValue, Is.Zero); - } else { + // pure dates var partValue = reader.GetDouble(0); CheckPartNative(partValue, expectedValueNative, aliasesEnabled); } @@ -632,21 +655,26 @@ private void TestDateTimePartExtraction(string table, SqlDateTimePart part, int using (var reader = command.ExecuteReader()) { while (reader.Read()) { - if (aliasesEnabled && part != SqlDateTimePart.Year) { - // year from +-infinity -> +-infinity + if (aliasesEnabled) { + // +-infinify + // year from +-infinity -> +-infinity (or 0 in case of versions older than 9.6) // month from +-infinity -> null (or 0 in case of versions older that 9.6) - if (Driver.CoreServerInfo.ServerVersion >= StorageProviderVersion.PostgreSql96) - Assert.That(reader.IsDBNull(0)); + if (Driver.CoreServerInfo.ServerVersion >= StorageProviderVersion.PostgreSql96) { + if (part != SqlDateTimePart.Year) { + Assert.That(reader.IsDBNull(0)); + } + else { + var partValue = reader.GetDouble(0); + Assert.That(double.IsInfinity(partValue), Is.True); + } + } else { var partValue = reader.GetDouble(0); Assert.That(partValue, Is.Zero); } } - if (Driver.CoreServerInfo.ServerVersion < StorageProviderVersion.PostgreSql96) { - var partValue = reader.GetDouble(0); - Assert.That(partValue, Is.Zero); - } else { + // pure dates var partValue = reader.GetDouble(0); CheckPartNative(partValue, expectedValueNative, aliasesEnabled); } @@ -676,21 +704,26 @@ private void TestDateTimeOffsetPartExtraction(string table, SqlDateTimeOffsetPar using (var reader = command.ExecuteReader()) { while (reader.Read()) { - if (aliasesEnabled && part != SqlDateTimeOffsetPart.Year) { - // year from +-infinity -> +-infinity + if (aliasesEnabled) { + // +-infinify + // year from +-infinity -> +-infinity (or 0 in case of versions older than 9.6) // month from +-infinity -> null (or 0 in case of versions older that 9.6) - if (Driver.CoreServerInfo.ServerVersion >= StorageProviderVersion.PostgreSql96 ) - Assert.That(reader.IsDBNull(0)); + if (Driver.CoreServerInfo.ServerVersion >= StorageProviderVersion.PostgreSql96) { + if (part != SqlDateTimeOffsetPart.Year) { + Assert.That(reader.IsDBNull(0)); + } + else { + var partValue = reader.GetDouble(0); + Assert.That(double.IsInfinity(partValue), Is.True); + } + } else { var partValue = reader.GetDouble(0); Assert.That(partValue, Is.Zero); } } - if (Driver.CoreServerInfo.ServerVersion < StorageProviderVersion.PostgreSql96) { - var partValue = reader.GetDouble(0); - Assert.That(partValue, Is.Zero); - } else { + // pure dates var partValue = reader.GetDouble(0); CheckPartNative(partValue, expectedValueNative, aliasesEnabled); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffset/PartsExtractionTest.cs b/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffset/PartsExtractionTest.cs index e58ec3683..1c625da2a 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffset/PartsExtractionTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffset/PartsExtractionTest.cs @@ -40,9 +40,17 @@ public void ExtractYearMinValueTest() public void ExtractYearMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); + ExecuteInsideSession((s) => { - RunTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.Year + 1); - RunWrongTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.AddYears(-1).Year); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + RunTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.Year + 1); + RunWrongTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.AddYears(-1).Year); + } + else { + RunTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.Year); + RunWrongTest(s, c => c.MaxValue.Year == DateTimeOffset.MaxValue.AddYears(-1).Year); + } }); } @@ -74,9 +82,17 @@ public void ExtractMonthMinValueTest() public void ExtractMonthMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); + ExecuteInsideSession((s) => { - RunTest(s, c => c.MaxValue.Month == DateTimeOffset.MaxValue.Month - 11); - RunWrongTest(s, c => c.MaxValue.Month == DateTimeOffset.MaxValue.AddMonths(-1).Month); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + RunTest(s, c => c.MaxValue.Month == 1); + RunWrongTest(s, c => c.MaxValue.Month == DateTimeOffset.MaxValue.AddMonths(-1).Month); + } + else { + RunTest(s, c => c.MaxValue.Month == 12); + RunWrongTest(s, c => c.MaxValue.Month == DateTimeOffset.MaxValue.AddMonths(-1).Month); + } }); } @@ -118,9 +134,17 @@ public void ExtractDayMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); ExecuteInsideSession((s) => { - // year overflow happens on server side because of timezone - RunTest(s, c => c.MaxValue.Day == 1); - RunWrongTest(s, c => c.MaxValue.Day == DateTimeOffset.MaxValue.AddDays(-1).Day); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + // year overflow happens on server side because of timezone + RunTest(s, c => c.MaxValue.Day == 1); + RunWrongTest(s, c => c.MaxValue.Day == DateTimeOffset.MaxValue.AddDays(-1).Day); + } + else { + // year overflow happens on server side because of timezone + RunTest(s, c => c.MaxValue.Day == 31); + RunWrongTest(s, c => c.MaxValue.Day == DateTimeOffset.MaxValue.AddDays(-1).Day); + } }); } @@ -152,48 +176,12 @@ public void ExtractHourMinValueTest() Require.ProviderIs(StorageProvider.PostgreSql); ExecuteInsideSession((s) => { - var service = s.Services.Get(); - - var command = service.CreateCommand(); - command.CommandText = $"SELECT COUNT(*) FROM public.\"MinMaxDateTimeOffsetEntity\" WHERE EXTRACT (HOUR FROM \"MinValue\") = 4"; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var rowCount = reader.GetInt32(0); - Console.WriteLine($"Rows with HOUR 4 : {rowCount}"); - } - } - - command = service.CreateCommand(); - command.CommandText = $"SELECT COUNT(*) FROM public.\"MinMaxDateTimeOffsetEntity\" WHERE EXTRACT (HOUR FROM \"MinValue\") = 5"; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var rowCount = reader.GetInt32(0); - Console.WriteLine($"Rows with HOUR 5 : {rowCount}"); - } - } - - command = service.CreateCommand(); - command.CommandText = $"SELECT (EXTRACT (TIMEZONE FROM \"MinValue\"))::integer FROM public.\"MinMaxDateTimeOffsetEntity\""; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var timezoneInSeconds = reader.GetDouble(0); - Console.WriteLine($"Timezone : {TimeSpan.FromSeconds(timezoneInSeconds)}"); - } - } - }); - - - ExecuteInsideSession((s) => { - RunTest(s, c => c.MinValue.Hour == 5); + var serverSideHours = (localTimezone > TimeSpan.Zero) + ? localTimezone.Hours // positive zone + : (localTimezone < TimeSpan.Zero) + ? 23 + localTimezone.Hours // negative zone + : localTimezone.Hours; // UTC + RunTest(s, c => c.MinValue.Hour == serverSideHours); RunWrongTest(s, c => c.MinValue.Hour == DateTimeOffset.MinValue.AddHours(1).Hour); }); } @@ -204,47 +192,12 @@ public void ExtractHourMaxValueTest() Require.ProviderIs(StorageProvider.PostgreSql); ExecuteInsideSession((s) => { - var service = s.Services.Get(); - - var command = service.CreateCommand(); - command.CommandText = $"SELECT COUNT(*) FROM public.\"MinMaxDateTimeOffsetEntity\" WHERE EXTRACT (HOUR FROM \"MaxValue\") = 4"; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var rowCount = reader.GetInt32(0); - Console.WriteLine($"Rows with HOUR 4 : {rowCount}"); - } - } - - command = service.CreateCommand(); - command.CommandText = $"SELECT COUNT(*) FROM public.\"MinMaxDateTimeOffsetEntity\" WHERE EXTRACT (HOUR FROM \"MaxValue\") = 5"; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var rowCount = reader.GetInt32(0); - Console.WriteLine($"Rows with HOUR 5 : {rowCount}"); - } - } - - command = service.CreateCommand(); - command.CommandText = $"SELECT (EXTRACT (TIMEZONE FROM \"MaxValue\"))::integer FROM public.\"MinMaxDateTimeOffsetEntity\""; - - using (command) - using (var reader = command.ExecuteReader()) { - - while (reader.Read()) { - var timezoneInSeconds = reader.GetDouble(0); - Console.WriteLine($"Timezone : {TimeSpan.FromSeconds(timezoneInSeconds)}"); - } - } - }); - - ExecuteInsideSession((s) => { - RunTest(s, c => c.MaxValue.Hour == 4); + var serverSideHours = (localTimezone > TimeSpan.Zero) + ? localTimezone.Hours - 1 // positive zone + : (localTimezone < TimeSpan.Zero) + ? 23 + localTimezone.Hours // negative zone + : 23; // UTC + RunTest(s, c => c.MaxValue.Hour == serverSideHours); RunWrongTest(s, c => c.MaxValue.Hour == DateTimeOffset.MaxValue.AddHours(-1).Hour); }); } @@ -381,11 +334,19 @@ public void ExtractDateMinValueTest() public void ExtractDateMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); - ExecuteInsideSession((s) => { - // overflow of year from 9999-12-31 to 10000-01-01 because of how postgre works with timezones - // can't validate - RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); - RunWrongTest(s, c => c.MaxValue.Date == DateTimeOffset.MaxValue.AddDays(-1).Date); + + ExecuteInsideSession((s) => { + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + // overflow of year from 9999-12-31 to 10000-01-01 because of how postgre works with timezones + // can't validate + RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); + RunWrongTest(s, c => c.MaxValue.Date == DateTimeOffset.MaxValue.AddDays(-1).Date); + } + else { + RunTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); + RunWrongTest(s, c => c.MaxValue.Date == DateTimeOffset.MaxValue.AddDays(-2).Date); + } }); } @@ -512,8 +473,15 @@ public void ExtractDayOfYearMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); ExecuteInsideSession((s) => { - RunTest(s, c => c.MaxValue.DayOfYear == 1); - RunWrongTest(s, c => c.MaxValue.DayOfYear == DateTimeOffset.MaxValue.AddDays(-1).DayOfYear); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + RunTest(s, c => c.MaxValue.DayOfYear == 1); + RunWrongTest(s, c => c.MaxValue.DayOfYear == DateTimeOffset.MaxValue.AddDays(-1).DayOfYear); + } + else { + RunTest(s, c => c.MaxValue.DayOfYear == DateTimeOffset.MaxValue.DayOfYear); + RunWrongTest(s, c => c.MaxValue.DayOfYear == DateTimeOffset.MaxValue.AddDays(-1).DayOfYear); + } }); } @@ -551,8 +519,15 @@ public void ExtractDayOfWeekMaxValueTest() { Require.ProviderIs(StorageProvider.PostgreSql); ExecuteInsideSession((s) => { - RunTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.DayOfWeek + 1); - RunWrongTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.AddDays(-1).DayOfWeek); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + RunTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.DayOfWeek + 1); + RunWrongTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.AddDays(-1).DayOfWeek); + } + else { + RunTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.DayOfWeek); + RunWrongTest(s, c => c.MaxValue.DayOfWeek == DateTimeOffset.MaxValue.AddDays(-1).DayOfWeek); + } }); } @@ -593,8 +568,16 @@ public void ExtractDateTimeMaxValueTest() ExecuteInsideSession((s) => { // overflow of year from 9999-12-31 to 10000-01-01 because of how postgre works with timezones // can't validate - RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); - RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.AddDays(-1).DateTime); + var overflowHappens = localTimezone > TimeSpan.Zero; + if (overflowHappens) { + RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); + RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.AddDays(-1).DateTime); + } + else { + RunTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.DateTime); + RunWrongTest(s, c => c.MaxValue.DateTime == DateTimeOffset.MaxValue.AddDays(-1).DateTime); + } + }); } diff --git a/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffsetBaseTest.cs b/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffsetBaseTest.cs index c298b24dc..7d888d7ae 100644 --- a/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffsetBaseTest.cs +++ b/Orm/Xtensive.Orm.Tests/Linq/DateTimeAndDateTimeOffset/DateTimeOffsetBaseTest.cs @@ -35,6 +35,8 @@ public abstract class DateTimeOffsetBaseTest : BaseTest protected static readonly DateTimeOffset SecondMillisecondDateTimeOffset = new DateTimeOffset(SecondMillisecondDateTime, SecondOffset); protected static readonly DateTimeOffset WrongMillisecondDateTimeOffset = new DateTimeOffset(WrongMillisecondDateTime, WrongOffset); + protected static readonly TimeSpan localTimezone = DateTimeOffset.Now.ToLocalTime().Offset; + protected override void RegisterTypes(DomainConfiguration configuration) { configuration.Types.Register(typeof(SingleDateTimeOffsetEntity)); @@ -51,7 +53,7 @@ protected override void InitializeCustomSettings(DomainConfiguration configurati { var providerInfo = StorageProviderInfo.Instance.Info; if (providerInfo.ProviderName==WellKnown.Provider.PostgreSql) { - var localZone = DateTimeOffset.Now.ToLocalTime().Offset; + var localZone = localTimezone; var localZoneString = ((localZone < TimeSpan.Zero) ? "-" : "+") + localZone.ToString(@"hh\:mm"); configuration.ConnectionInitializationSql = string.Format("SET TIME ZONE INTERVAL '{0}' HOUR TO MINUTE", localZoneString); }