Skip to content

Commit 876b45a

Browse files
committed
Merge branch 'master' into master-stringoperations-imp
# Conflicts: # Orm/Xtensive.Orm.Tests/Storage/Providers/Sql/StringOperationsTest.cs
2 parents e281961 + 24fc39f commit 876b45a

39 files changed

+7313
-10892
lines changed

ChangeLog/7.1.4_Z_Final.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[main] Addressed IndexOutOfRangeException on translation of certain queries with aggregates
2+
[main] Notification to BuildLog when a hierarchy changes KeyGeneratorKind value to None
3+
[postgresql] Added explicit nulls setting for both column order directions to improve OrderBy/OrderByDescending performance

Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/DomainHandler.cs

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using Xtensive.Core;
1111
using Xtensive.Orm.Rse.Compilation;
12+
using Xtensive.Orm.Rse.Transformation;
1213

1314
namespace Xtensive.Orm.Providers.PostgreSql
1415
{
@@ -21,6 +22,12 @@ public class DomainHandler : Providers.DomainHandler
2122
protected override ICompiler CreateCompiler(CompilerConfiguration configuration) =>
2223
new SqlCompiler(Handlers, configuration);
2324

25+
protected override IPreCompiler CreatePreCompiler(CompilerConfiguration configuration)
26+
{
27+
var decimalAggregateCorrector = new AggregateOverDecimalColumnCorrector(Handlers.Domain.Model);
28+
return new CompositePreCompiler(decimalAggregateCorrector, base.CreatePreCompiler(configuration));
29+
}
30+
2431
/// <inheritdoc/>
2532
protected override IEnumerable<Type> GetProviderCompilerContainers()
2633
{

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v9_0/Translator.cs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public override void Translate(SqlCompilerContext context, object literalValue)
3030
}
3131
}
3232

33+
public override void TranslateSortOrder(IOutput output, bool ascending) =>
34+
output.Append(ascending ? "ASC NULLS FIRST" : "DESC NULLS LAST");
35+
3336
// Constructors
3437

3538
public Translator(SqlDriver driver)

Orm/Xtensive.Orm.Tests.Framework/AutoBuildTest.cs

+31-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,26 @@ namespace Xtensive.Orm.Tests
1818
public abstract class AutoBuildTest : HasConfigurationAccessTest
1919
{
2020
private const string ErrorInTestFixtureSetup = "Error in TestFixtureSetUp:\r\n{0}";
21+
private const string ErrorNotInitializedGlobalSession = "Set InitGlobalSession to true";
22+
2123
private DisposableSet disposables;
24+
private (Session session, TransactionScope transaction) globalSessionAndTransaction;
25+
26+
/// <summary>
27+
/// If set to <see langword="true"/>, global session and transaction will be opened
28+
/// to use one session accross all test methods.
29+
/// </summary>
30+
protected virtual bool InitGlobalSession => false;
2231

2332
protected ProviderInfo ProviderInfo { get; set; }
2433
protected Domain Domain { get; set; }
2534

35+
// Use these two for read-only tests only, don't change them, they are controlled by AutoBuildTest.
36+
// If there is need to change Session/Transactionscope or add/modify/remove entities
37+
// then open dedicated Session/TransactionScope within test
38+
protected Session GlobalSession => InitGlobalSession ? globalSessionAndTransaction.session : throw new Exception(ErrorNotInitializedGlobalSession);
39+
protected TransactionScope GlobalTransaction => InitGlobalSession ? globalSessionAndTransaction.transaction : throw new Exception(ErrorNotInitializedGlobalSession);
40+
2641
[OneTimeSetUp]
2742
public virtual void TestFixtureSetUp()
2843
{
@@ -58,10 +73,16 @@ protected void RebuildDomain()
5873

5974
var config = BuildConfiguration();
6075
Domain = BuildDomain(config);
61-
PopulateData();
62-
63-
if (Domain!=null)
76+
if (Domain != null) {
6477
ProviderInfo = Domain.StorageProviderInfo;
78+
if (InitGlobalSession) {
79+
globalSessionAndTransaction = CreateSessionAndTransaction();
80+
}
81+
}
82+
else {
83+
ProviderInfo = StorageProviderInfo.Instance.Info;
84+
}
85+
PopulateData();
6586
}
6687

6788
protected virtual void PopulateData()
@@ -74,17 +95,21 @@ protected virtual void CheckRequirements()
7495

7596
protected (Session, TransactionScope) CreateSessionAndTransaction()
7697
{
98+
var initDisposable = disposables is null;
7799
try {
78-
disposables = new DisposableSet();
100+
if (initDisposable)
101+
disposables = new DisposableSet();
79102
var session = Domain.OpenSession();
80103
var transaction = session.OpenTransaction();
81104
_ = disposables.Add(session);
82105
_ = disposables.Add(transaction);
83106
return (session, transaction);
84107
}
85108
catch {
86-
disposables.DisposeSafely();
87-
disposables = null;
109+
if (initDisposable) {
110+
disposables.DisposeSafely();
111+
disposables = null;
112+
}
88113
throw;
89114
}
90115
}

Orm/Xtensive.Orm.Tests.Framework/Internals/KeyValuePairInstanceGenerator.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
1+
// Copyright (C) 2003-2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Alex Yakunin
@@ -13,13 +13,13 @@ namespace Xtensive.Orm.Tests
1313
[Serializable]
1414
internal class ArrayInstanceGenerator<T>: WrappingInstanceGenerator<T[], T>
1515
{
16-
public const int ArrayLenght = 100;
16+
public const int ArrayLength = 100;
1717

1818
public override T[] GetInstance(Random random)
1919
{
20-
T[] result = new T[ArrayLenght];
20+
T[] result = new T[ArrayLength];
2121
int i = 0;
22-
foreach (T t in BaseGenerator.GetInstances(random, ArrayLenght)) {
22+
foreach (T t in BaseGenerator.GetInstances(random, ArrayLength)) {
2323
result[i] = t;
2424
i++;
2525
}

0 commit comments

Comments
 (0)