Skip to content

Commit 188a865

Browse files
committed
Merge branch 'master' into InClause
2 parents 9efea3f + 3873844 commit 188a865

File tree

218 files changed

+3917
-717
lines changed

Some content is hidden

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

218 files changed

+3917
-717
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ insert_final_newline = true
77
indent_style = tab
88
dotnet_sort_system_directives_first = true
99
csharp_space_after_cast = true
10+
csharp_new_line_before_open_brace = all
11+
csharp_new_line_before_else = true
12+
csharp_new_line_before_catch = true
13+
csharp_new_line_before_finally = true
14+
csharp_new_line_before_members_in_object_initializers = true
15+
csharp_new_line_before_members_in_anonymous_types = true
16+
csharp_new_line_between_query_expression_clauses = true
1017

1118
[*.xsd]
1219
indent_style = tab

Tools/packages.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="NUnit.Console" version="3.7.0" targetFramework="net461" />
4-
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net461" />
3+
<package id="NUnit.Console" version="3.10.0" targetFramework="net461" />
4+
<package id="NUnit.ConsoleRunner" version="3.10.0" targetFramework="net461" />
55
<package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net461" />
66
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net461" />
77
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
8-
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
9-
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
8+
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.6" targetFramework="net461" />
9+
<package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net461" />
1010
<package id="CSharpAsyncGenerator.CommandLine" version="0.14.0" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
12-
<package id="gitreleasemanager" version="0.7.0" targetFramework="net461" />
12+
<package id="GitReleaseManager" version="0.7.0" targetFramework="net461" />
1313
</packages>

src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
<None Include="..\NHibernate.Test\App.config" Link="App.config" />
3333
</ItemGroup>
3434
<ItemGroup>
35+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
3536
<PackageReference Include="Microsoft.VisualBasic" Version="10.2.0" />
37+
<PackageReference Include="NUnit" Version="3.12.0" />
38+
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
3639
</ItemGroup>
3740
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
38-
<PackageReference Include="NUnitLite" Version="3.10.1" />
41+
<PackageReference Include="NUnitLite" Version="3.12.0" />
3942
</ItemGroup>
4043
<ItemGroup>
4144
<ProjectReference Include="..\NHibernate\NHibernate.csproj" />

src/NHibernate.Test/Async/CfgTest/ConfigurationFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System;
1212
using System.Collections;
1313
using System.IO;
14+
using System.Linq;
1415
using System.Xml;
1516
using NHibernate.Cfg;
1617
using NHibernate.DomainModel;
@@ -107,6 +108,15 @@ public SampleQueryProvider(ISessionImplementor session) : base(session)
107108
{
108109

109110
}
111+
112+
protected SampleQueryProvider(ISessionImplementor session, object collection, NhQueryableOptions options) : base(session, collection, options)
113+
{
114+
}
115+
116+
protected override IQueryProvider CreateWithOptions(NhQueryableOptions options)
117+
{
118+
return new SampleQueryProvider(Session, Collection, options);
119+
}
110120
}
111121

112122
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NHibernate.Cfg.MappingSchema;
12+
using NHibernate.Dialect;
13+
using NHibernate.Mapping.ByCode;
14+
using NUnit.Framework;
15+
16+
namespace NHibernate.Test.Hql
17+
{
18+
using System.Threading.Tasks;
19+
using System.Threading;
20+
[TestFixture]
21+
public class AggregateFunctionsWithSubSelectTestAsync : TestCaseMappingByCode
22+
{
23+
protected override HbmMapping GetMappings()
24+
{
25+
var mapper = new ModelMapper();
26+
mapper.Class<Person>(
27+
rc =>
28+
{
29+
rc.Id(x => x.Id, m => m.Generator(Generators.Native));
30+
rc.Property(x => x.Name);
31+
rc.Map(x => x.Localized, cm => cm.Cascade(Mapping.ByCode.Cascade.All), x => x.Element());
32+
});
33+
34+
mapper.Class<Document>(
35+
rc =>
36+
{
37+
rc.Id(x => x.Id, m => m.Generator(Generators.Native));
38+
rc.Property(x => x.Name);
39+
rc.Map(x => x.Contacts, cm => cm.Key(k => k.Column("position")), x => x.OneToMany());
40+
});
41+
42+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
43+
}
44+
45+
protected override void OnTearDown()
46+
{
47+
using (var session = OpenSession())
48+
using (var transaction = session.BeginTransaction())
49+
{
50+
session.Delete("from System.Object");
51+
52+
session.Flush();
53+
transaction.Commit();
54+
}
55+
}
56+
57+
protected override void OnSetUp()
58+
{
59+
using (var session = OpenSession())
60+
using (var transaction = session.BeginTransaction())
61+
{
62+
var document = new Document();
63+
var p1 = new Person();
64+
var p2 = new Person();
65+
66+
p1.Localized.Add(1, "p1.1");
67+
p1.Localized.Add(2, "p1.2");
68+
p2.Localized.Add(1, "p2.1");
69+
p2.Localized.Add(2, "p2.2");
70+
71+
document.Contacts.Add(1, p1);
72+
document.Contacts.Add(2, p2);
73+
74+
session.Persist(p1);
75+
session.Persist(p2);
76+
session.Persist(document);
77+
78+
transaction.Commit();
79+
}
80+
}
81+
82+
protected override bool AppliesTo(Dialect.Dialect dialect)
83+
{
84+
return TestDialect.SupportsAggregateInSubSelect;
85+
}
86+
87+
[TestCase("SUM", 4)]
88+
[TestCase("MIN", 2)]
89+
[TestCase("MAX", 2)]
90+
[TestCase("AVG", 2d)]
91+
public async Task TestAggregateFunctionAsync(string functionName, object result, CancellationToken cancellationToken = default(CancellationToken))
92+
{
93+
var query = "SELECT " +
94+
" d.Id, " +
95+
$" {functionName}(" +
96+
" (" +
97+
" SELECT COUNT(localized) " +
98+
" FROM Person p " +
99+
" LEFT JOIN p.Localized localized " +
100+
" WHERE p.Id = c.Id" +
101+
" )" +
102+
" ) AS LocalizedCount " +
103+
"FROM Document d " +
104+
"LEFT JOIN d.Contacts c " +
105+
"GROUP BY d.Id";
106+
107+
using (var session = OpenSession())
108+
using (var transaction = session.BeginTransaction())
109+
{
110+
var results = await (session.CreateQuery(query).ListAsync(cancellationToken));
111+
112+
Assert.That(results, Has.Count.EqualTo(1));
113+
var tuple = results[0] as object[];
114+
Assert.That(tuple, Is.Not.Null);
115+
Assert.That(tuple, Has.Length.EqualTo(2));
116+
Assert.That(tuple[1], Is.EqualTo(result));
117+
await (transaction.CommitAsync(cancellationToken));
118+
}
119+
}
120+
}
121+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using NHibernate.Cfg.MappingSchema;
12+
using NHibernate.Mapping.ByCode;
13+
using NUnit.Framework;
14+
15+
namespace NHibernate.Test.Hql
16+
{
17+
using System.Threading.Tasks;
18+
[TestFixture]
19+
public class SubQueryTestAsync : TestCaseMappingByCode
20+
{
21+
protected override HbmMapping GetMappings()
22+
{
23+
var mapper = new ModelMapper();
24+
mapper.Class<Root>(
25+
rc =>
26+
{
27+
rc.Id(x => x.Id, m => m.Generator(Generators.Native));
28+
rc.Property(x => x.RootName);
29+
rc.ManyToOne(x => x.Branch);
30+
});
31+
32+
mapper.Class<Branch>(
33+
rc =>
34+
{
35+
rc.Id(x => x.Id, m => m.Generator(Generators.Native));
36+
rc.Property(x => x.BranchName);
37+
rc.Bag(x => x.Leafs, cm => cm.Cascade(Mapping.ByCode.Cascade.All), x => x.OneToMany());
38+
});
39+
mapper.Class<Leaf>(
40+
rc =>
41+
{
42+
rc.Id(x => x.Id, m => m.Generator(Generators.Native));
43+
rc.Property(x => x.LeafName);
44+
});
45+
46+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
47+
}
48+
49+
protected override bool AppliesTo(Dialect.Dialect dialect)
50+
{
51+
return dialect.SupportsScalarSubSelects;
52+
}
53+
54+
[TestCase("SELECT CASE WHEN l.id IS NOT NULL THEN (SELECT COUNT(r.id) FROM Root r) ELSE 0 END FROM Leaf l")]
55+
[TestCase("SELECT CASE WHEN (SELECT COUNT(r.id) FROM Root r) > 1 THEN 1 ELSE 0 END FROM Leaf l")]
56+
[TestCase("SELECT CASE WHEN l.id > 1 THEN 1 ELSE (SELECT COUNT(r.id) FROM Root r) END FROM Leaf l")]
57+
[TestCase("SELECT CASE (SELECT COUNT(r.id) FROM Root r) WHEN 1 THEN 1 ELSE 0 END FROM Leaf l")]
58+
[TestCase("SELECT CASE l.id WHEN (SELECT COUNT(r.id) FROM Root r) THEN 1 ELSE 0 END FROM Leaf l")]
59+
public async Task TestSubQueryAsync(string query)
60+
{
61+
using (var session = OpenSession())
62+
using (var transaction = session.BeginTransaction())
63+
{
64+
// Simple syntax check
65+
await (session.CreateQuery(query).ListAsync());
66+
await (transaction.CommitAsync());
67+
}
68+
}
69+
}
70+
}

src/NHibernate.Test/Async/NHSpecificTest/GH0000/Fixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected override void OnTearDown()
4141
// The HQL delete does all the job inside the database without loading the entities, but it does
4242
// not handle delete order for avoiding violating constraints if any. Use
4343
// session.Delete("from System.Object");
44-
// instead if in need of having NHbernate ordering the deletes, but this will cause
44+
// instead if in need of having NHibernate ordering the deletes, but this will cause
4545
// loading the entities in the session.
4646
session.CreateQuery("delete from System.Object").ExecuteUpdate();
4747

src/NHibernate.Test/Async/NHSpecificTest/GH1879/FixtureByCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Collections.Generic;
1313
using System.Linq;
1414
using NHibernate.Cfg.MappingSchema;
15+
using NHibernate.Exceptions;
1516
using NHibernate.Mapping.ByCode;
1617
using NHibernate.Type;
1718
using NUnit.Framework;
@@ -124,8 +125,7 @@ protected async Task AreEqualAsync<TResult>(
124125
{
125126
expectedResult = await (expectedQuery(session.Query<T>()).ToListAsync(cancellationToken));
126127
}
127-
catch (OperationCanceledException) { throw; }
128-
catch (Exception e)
128+
catch (GenericADOException e)
129129
{
130130
Assert.Ignore($"Not currently supported query: {e}");
131131
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Linq;
13+
using NHibernate.UserTypes;
14+
using NUnit.Framework;
15+
using NHibernate.Linq;
16+
17+
namespace NHibernate.Test.NHSpecificTest.GH1963
18+
{
19+
using System.Threading.Tasks;
20+
[TestFixture]
21+
public class FixtureAsync : BugTestCase
22+
{
23+
protected override void OnSetUp()
24+
{
25+
using (var session = OpenSession())
26+
using (var transaction = session.BeginTransaction())
27+
{
28+
var e1 = new Entity {Name = "Bob", Flag = true};
29+
session.Save(e1);
30+
31+
var e2 = new Entity {Name = "Sally"};
32+
session.Save(e2);
33+
34+
transaction.Commit();
35+
}
36+
}
37+
38+
protected override void OnTearDown()
39+
{
40+
using (var session = OpenSession())
41+
using (var transaction = session.BeginTransaction())
42+
{
43+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
44+
45+
transaction.Commit();
46+
}
47+
}
48+
49+
[Test]
50+
public void LinqFilterOnNonLiteralCustomTypeAsync()
51+
{
52+
using (var session = OpenSession())
53+
using (session.BeginTransaction())
54+
{
55+
var result = from e in session.Query<Entity>()
56+
where e.Flag
57+
select e;
58+
59+
Assert.That(
60+
() => result.ToListAsync(),
61+
Throws
62+
.InnerException.TypeOf<InvalidOperationException>()
63+
.And.InnerException.Message.Contains(nameof(IEnhancedUserType)));
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)