Skip to content

Commit bcaab42

Browse files
committed
Merge branch '7.2' into 7.2-no-exception-overwrite-on-commit-upgrade
# Conflicts: # ChangeLog/7.2.1-dev.txt
2 parents 458e0ae + 2d33dea commit bcaab42

26 files changed

Lines changed: 1127 additions & 282 deletions

ChangeLog/7.2.1-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
[main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed
1+
[main] Added Query.SingleAsync()/SingleOrDefaultAsync and QueryEndpoint.SingleAsync()/SingleOrDefaultAsync methods
2+
[main] Addressed issue of not disposing IAsyncEnumerator which caused query being open
3+
[main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed

Orm/Xtensive.Orm.Tests.Framework/Orm.config

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
<domain name="mssql2022"
3737
connectionUrl="sqlserver://dotest:dotest@localhost\DO_SQL2022:1422/DO-Tests?MultipleActiveResultSets=True" />
3838

39+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
40+
<!-- This allows to override it in storage configuration files -->
41+
<domain name="mssqlnext"
42+
connectionUrl="sqlserver://localhost/DO-Tests?MultipleActiveResultSets=True" />
43+
3944
<domain name="pgsql83"
4045
connectionUrl="postgresql://dotest:dotest@localhost:5483/dotest" />
4146

@@ -81,12 +86,22 @@
8186
<domain name="pgsql180"
8287
connectionUrl="postgresql://dotest:dotest@localhost:54180/dotest" />
8388

89+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
90+
<!-- This allows to override it in storage configuration files -->
91+
<domain name="pgsqlnext"
92+
connectionUrl="postgresql://dotest:dotest@localhost:54170/dotest" />
93+
8494
<domain name="oracle10"
8595
connectionUrl="oracle://dotest:dotest@localhost:5510/ora10" />
8696

8797
<domain name="oracle11"
8898
connectionUrl="oracle://dotest:dotest@localhost:5511/ora11" />
8999

100+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
101+
<!-- This allows to override it in storage configuration files -->
102+
<domain name="oraclenext"
103+
connectionUrl="oracle://dotest:dotest@localhost:5511/ora11" />
104+
90105
<domain name="mysql55"
91106
connectionUrl="mysql://dotest:dotest@localhost:3355/dotest" />
92107

@@ -123,6 +138,11 @@
123138
<domain name="mysql93"
124139
connectionUrl="mysql://dotest:dotest@localhost:3393/dotest" />
125140

141+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
142+
<!-- This allows to override it in storage configuration files -->
143+
<domain name="mysqlnext"
144+
connectionUrl="mysql://dotest:dotest@localhost:3390/dotest" />
145+
126146
<domain name="firebird25"
127147
connectionUrl="firebird://dotest:dotest@localhost:3050/dotest" />
128148

@@ -135,6 +155,11 @@
135155
<domain name="firebird50"
136156
connectionUrl="firebird://dotest:dotest@localhost:3055/dotest" />
137157

158+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
159+
<!-- This allows to override it in storage configuration files -->
160+
<domain name="firebirdnext"
161+
connectionUrl="firebird://dotest:dotest@localhost:3055/dotest" />
162+
138163
<domain name="sqlite3"
139164
connectionUrl="sqlite:///DO-Tests.db3" />
140165

@@ -170,6 +195,11 @@
170195
<domain name="mssql2022cs" provider="sqlserver"
171196
connectionString="Data Source=localhost\DO_SQL2022,1422;Initial Catalog=DO-Tests;User ID=dotest;Password=dotest;MultipleActiveResultSets=True;Encrypt=false" />
172197

198+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
199+
<!-- This allows to override it in storage configuration files -->
200+
<domain name="mssqlnextcs" provider="sqlserver"
201+
connectionString="Data Source=localhost;Initial Catalog=DO-Tests;Integrated Security=True;MultipleActiveResultSets=True" />
202+
173203
<domain name="pgsql83cs" provider="postgresql"
174204
connectionString="HOST=localhost;PORT=5483;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest" />
175205

@@ -215,12 +245,22 @@
215245
<domain name="pgsql180cs" provider="postgresql"
216246
connectionString="HOST=localhost;PORT=54180;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest" />
217247

248+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
249+
<!-- This allows to override it in storage configuration files -->
250+
<domain name="pgsqlnextcs" provider="postgresql"
251+
connectionString="HOST=localhost;PORT=54170;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest" />
252+
218253
<domain name="oracle10cs" provider="oracle"
219254
connectionString="DATA SOURCE=&quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=5510))(CONNECT_DATA=(SERVICE_NAME=ora10)))&quot;;USER ID=dotest;PASSWORD=dotest" />
220255

221256
<domain name="oracle11cs" provider="oracle"
222257
connectionString="DATA SOURCE=&quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=5511))(CONNECT_DATA=(SERVICE_NAME=ora11)))&quot;;USER ID=dotest;PASSWORD=dotest" />
223258

259+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
260+
<!-- This allows to override it in storage configuration files -->
261+
<domain name="oraclenextcs" provider="oracle"
262+
connectionString="DATA SOURCE=&quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=5511))(CONNECT_DATA=(SERVICE_NAME=ora11)))&quot;;USER ID=dotest;PASSWORD=dotest" />
263+
224264
<domain name="mysql55cs" provider="mysql"
225265
connectionString="Server=localhost;Port=3355;Database=dotest;Uid=dotest;Pwd=dotest" />
226266

@@ -257,6 +297,11 @@
257297
<domain name="mysql93cs" provider="mysql"
258298
connectionString="Server=localhost;Port=3393;Database=dotest;Uid=dotest;Pwd=dotest" />
259299

300+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
301+
<!-- This allows to override it in storage configuration files -->
302+
<domain name="mysqlnextcs" provider="mysql"
303+
connectionString="Server=localhost;Port=3393;Database=dotest;Uid=dotest;Pwd=dotest" />
304+
260305
<domain name="firebird25cs" provider="firebird"
261306
connectionString="User=dotest;Password=dotest;Database=dotest;DataSource=localhost;Port=3050;Dialect=3;Charset=UTF8;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0" />
262307

@@ -269,6 +314,11 @@
269314
<domain name="firebird50cs" provider="firebird"
270315
connectionString="User=dotest;Password=dotest;Database=dotest;DataSource=localhost;Port=3055;Dialect=3;Charset=UTF8;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0" />
271316

317+
<!-- A hook to have abitity to check and test newer, yet not supported, versions without adding them to the file -->
318+
<!-- This allows to override it in storage configuration files -->
319+
<domain name="firebirdnextcs" provider="firebird"
320+
connectionString="User=dotest;Password=dotest;Database=dotest;DataSource=localhost;Port=3055;Dialect=3;Charset=UTF8;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0" />
321+
272322
<domain name="sqlite3cs" provider="sqlite"
273323
connectionString="Data Source=DO-Tests.db3" />
274324
</domains>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (C) 2026 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using Xtensive.Core;
7+
8+
namespace Xtensive.Orm.Tests
9+
{
10+
public sealed class QueryExecutionDetector
11+
{
12+
private int dbCommandCounter = 0;
13+
private int queryCounter = 0;
14+
15+
public bool DbCommandsDetected => dbCommandCounter > 0;
16+
public bool QueriesDetected => queryCounter > 0;
17+
18+
public IDisposable Attach(Session session)
19+
{
20+
session.Events.DbCommandExecuted += Events_DbCommandExecuted;
21+
22+
return new Disposable((b) => { session.Events.DbCommandExecuted -= Events_DbCommandExecuted; });
23+
}
24+
25+
public void Reset()
26+
{
27+
dbCommandCounter = 0;
28+
queryCounter = 0;
29+
}
30+
31+
private void Events_DbCommandExecuted(object sender, DbCommandEventArgs e) => dbCommandCounter++;
32+
}
33+
}

Orm/Xtensive.Orm.Tests/Interfaces/KeyStructureConflictTest.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,17 @@ public class Child2 : Root2, IChild
4545

4646
namespace Xtensive.Orm.Tests.Interfaces
4747
{
48-
public class KeyStructureConflictTest : AutoBuildTest
48+
public class KeyStructureConflictTest
4949
{
50-
protected override DomainConfiguration BuildConfiguration()
50+
[Test]
51+
public void MainTest()
5152
{
52-
var config = base.BuildConfiguration();
53+
var config = DomainConfigurationFactory.Create();
5354
config.Types.RegisterCaching(typeof (Root1).Assembly, typeof (Root1).Namespace);
54-
return config;
55-
}
56-
57-
protected override Domain BuildDomain(DomainConfiguration configuration)
58-
{
59-
try {
60-
base.BuildDomain(configuration);
61-
Assert.Fail();
62-
}
63-
catch (DomainBuilderException e) {
64-
Console.WriteLine(e);
65-
}
66-
return null;
55+
var ex = Assert.Throws<DomainBuilderException>(() => Domain.Build(config));
56+
var message = ex.Message;
57+
Assert.That(message.Contains("IChild") && message.Contains("different key structure") && message.Contains("Root1 & Root2"),
58+
Is.True);
6759
}
6860
}
6961
}

Orm/Xtensive.Orm.Tests/Interfaces/TypeIdModeConflictTest.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,17 @@ public class Root2 : Entity, IRoot
3434

3535
namespace Xtensive.Orm.Tests.Interfaces
3636
{
37-
public class TypeIdModeConflictTest : AutoBuildTest
37+
public class TypeIdModeConflictTest
3838
{
39-
protected override DomainConfiguration BuildConfiguration()
39+
[Test]
40+
public void MainTest()
4041
{
41-
var config = base.BuildConfiguration();
42+
var config = DomainConfigurationFactory.Create();
4243
config.Types.RegisterCaching(typeof (Root1).Assembly, typeof (Root1).Namespace);
43-
return config;
44-
}
45-
46-
protected override Domain BuildDomain(DomainConfiguration configuration)
47-
{
48-
try {
49-
base.BuildDomain(configuration);
50-
Assert.Fail();
51-
}
52-
catch (DomainBuilderException e) {
53-
Console.WriteLine(e);
54-
}
55-
return null;
44+
var ex = Assert.Throws<DomainBuilderException>(() => Domain.Build(config));
45+
var message = ex.Message;
46+
Assert.That(message.Contains("IRoot") && message.Contains("one of which includes TypeId, but another doesn't") && message.Contains("Root1 & Root2"),
47+
Is.True);
5648
}
5749
}
5850
}

Orm/Xtensive.Orm.Tests/Interfaces/UnusedTypeRemovalTest.cs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,18 @@ public class First : Entity, IFirst
5151

5252
namespace Xtensive.Orm.Tests.Interfaces
5353
{
54-
public class UnusedTypeRemovalTest : AutoBuildTest
54+
public class UnusedTypeRemovalTest
5555
{
5656
[Test]
5757
public void MainTest()
5858
{
59-
Assert.IsNull(Domain);
60-
}
59+
var config = DomainConfigurationFactory.Create();
60+
config.Types.RegisterCaching(typeof(IFirst).Assembly, typeof(IFirst).Namespace);
6161

62-
protected override DomainConfiguration BuildConfiguration()
63-
{
64-
var config = base.BuildConfiguration();
65-
config.Types.RegisterCaching(typeof (IFirst).Assembly, typeof (IFirst).Namespace);
66-
return config;
67-
}
68-
69-
protected override Domain BuildDomain(DomainConfiguration configuration)
70-
{
71-
try {
72-
base.BuildDomain(configuration);
73-
Assert.Fail();
74-
}
75-
catch (DomainBuilderException e) {
76-
Console.WriteLine(e);
77-
}
78-
return null;
62+
var ex = Assert.Throws<DomainBuilderException>(() => Domain.Build(config));
63+
var message = ex.Message;
64+
Assert.That(message.Contains("ISecond") && message.Contains("don't belong") && message.Contains("hierarchy"),
65+
Is.True);
7966
}
8067
}
8168
}

Orm/Xtensive.Orm.Tests/Issues/Issue0262_StructureAssignment.cs

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -64,53 +64,40 @@ protected override DomainConfiguration BuildConfiguration()
6464
[Test]
6565
public void SetTest()
6666
{
67-
using (var session = Domain.OpenSession()) {
68-
using (var t = session.OpenTransaction()) {
69-
70-
var container = new Container();
71-
try {
72-
container.Value = new Triple();
73-
Assert.Fail();
74-
} catch (InvalidOperationException) {
75-
76-
}
77-
78-
// Rollback
79-
}
67+
using (var session = Domain.OpenSession())
68+
using (var t = session.OpenTransaction()) {
69+
70+
var container = new Container();
71+
_ = Assert.Throws<InvalidOperationException>(() => { container.Value = new Triple(); });
72+
73+
// Rollback
8074
}
8175
}
8276

8377
[Test]
8478
public void CastTest()
8579
{
86-
using (var session = Domain.OpenSession()) {
87-
using (var t = session.OpenTransaction()) {
88-
89-
var container = new Container();
90-
try {
91-
container.Value = (Pair)new Triple();
92-
Assert.Fail();
93-
} catch (InvalidOperationException) {
94-
95-
}
96-
97-
// Rollback
98-
}
80+
using (var session = Domain.OpenSession())
81+
using (var t = session.OpenTransaction()) {
82+
83+
var container = new Container();
84+
_ = Assert.Throws<InvalidOperationException>(() => { container.Value = (Pair) new Triple(); });
85+
86+
// Rollback
9987
}
10088
}
10189

10290
[Test]
10391
public void ValidTest()
10492
{
105-
using (var session = Domain.OpenSession()) {
106-
using (var t = session.OpenTransaction()) {
107-
108-
var container = new Container();
109-
var triple = new Triple();
110-
container.Value = new Pair(triple.One, triple.Two);
111-
112-
// Rollback
113-
}
93+
using (var session = Domain.OpenSession())
94+
using (var t = session.OpenTransaction()) {
95+
96+
var container = new Container();
97+
var triple = new Triple();
98+
container.Value = new Pair(triple.One, triple.Two);
99+
100+
// Rollback
114101
}
115102
}
116103
}

0 commit comments

Comments
 (0)