Skip to content

Commit 6a50cf7

Browse files
committed
Merge branch '3.3.x'
2 parents f6731ac + e187e95 commit 6a50cf7

29 files changed

+14991
-180
lines changed

lib/teamcity/mysql/NHibernate.Test.last-results.xml

Lines changed: 14378 additions & 0 deletions
Large diffs are not rendered by default.

lib/teamcity/sqlServerOdbc/NHibernate.Test.last-results.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9666,7 +9666,7 @@ TearDown : NHibernate.Exceptions.GenericADOException : could not load an entity:
96669666
<results>
96679667
<test-case name="NHibernate.Test.NHSpecificTest.NH2020.Fixture.ISQLExceptionConverter_gets_called_if_batch_size_enabled" executed="True" result="Failure" success="False" asserts="0">
96689668
<failure>
9669-
<message><![CDATA[The action (transaction => transaction.Commit()) Should Throw NHibernate.Exceptions.ConstraintViolationException.
9669+
<message><![CDATA[The action (transaction => transaction.Commit()) Should Throw NHibernate.Exceptions.ConstraintViolationException.
96709670
Threw: NHibernate.Exceptions.GenericADOException]]></message>
96719671
</failure>
96729672
</test-case>

src/NHibernate.Test/Component/Basic/ComponentWithUniqueConstraintTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public void CannotBePersistedWithNonUniqueValues()
8484
});
8585
Assert.That(exception.InnerException, Is.AssignableTo<DbException>());
8686
Assert.That(exception.InnerException.Message,
87-
Is.StringContaining("unique").IgnoreCase.And.StringContaining("constraint").IgnoreCase);
87+
Is.StringContaining("unique").IgnoreCase.And.StringContaining("constraint").IgnoreCase
88+
.Or.StringContaining("duplicate entry").IgnoreCase);
8889
}
8990
}
9091
}

src/NHibernate.Test/Hql/Ast/BulkManipulation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public void IncrementTimestampVersion()
431431

432432
DateTime initialVersion = entity.Version;
433433

434-
Thread.Sleep(300);
434+
Thread.Sleep(1300);
435435

436436
s = OpenSession();
437437
t = s.BeginTransaction();

src/NHibernate.Test/Hql/HQLFunctions.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static HQLFunctions()
1818
notSupportedStandardFunction =
1919
new Hashtable
2020
{
21-
{"locate", new[] {typeof (FirebirdDialect), typeof (PostgreSQLDialect), typeof (SQLiteDialect)}},
21+
{"locate", new[] {typeof (SQLiteDialect)}},
2222
{"bit_length", new[] {typeof (SQLiteDialect)}},
2323
{"extract", new[] {typeof (SQLiteDialect)}},
2424
{"nullif", new[] {typeof (Oracle8iDialect)}}
@@ -83,12 +83,12 @@ public void AggregateCount()
8383
Assert.AreEqual(2, result);
8484

8585
// Count in where
86-
if (TestDialect.SupportsHavingWithoutGroupBy)
87-
{
88-
result = s.CreateQuery("select count(a.id) from Animal a having count(a.id)>1").UniqueResult();
89-
Assert.AreEqual(typeof (long), result.GetType());
90-
Assert.AreEqual(2, result);
91-
}
86+
if (TestDialect.SupportsHavingWithoutGroupBy)
87+
{
88+
result = s.CreateQuery("select count(a.id) from Animal a having count(a.id)>1").UniqueResult();
89+
Assert.AreEqual(typeof (long), result.GetType());
90+
Assert.AreEqual(2, result);
91+
}
9292
}
9393
}
9494

@@ -111,12 +111,12 @@ public void AggregateAvg()
111111
Assert.AreEqual(15D, result);
112112

113113
// In where
114-
if (TestDialect.SupportsHavingWithoutGroupBy)
115-
{
116-
result = s.CreateQuery("select avg(a.BodyWeight) from Animal a having avg(a.BodyWeight)>0").UniqueResult();
117-
Assert.AreEqual(typeof(double), result.GetType());
118-
Assert.AreEqual(15D, result);
119-
}
114+
if (TestDialect.SupportsHavingWithoutGroupBy)
115+
{
116+
result = s.CreateQuery("select avg(a.BodyWeight) from Animal a having avg(a.BodyWeight)>0").UniqueResult();
117+
Assert.AreEqual(typeof(double), result.GetType());
118+
Assert.AreEqual(15D, result);
119+
}
120120
}
121121
}
122122

@@ -137,12 +137,12 @@ public void AggregateMax()
137137
Assert.AreEqual(typeof(float), result.GetType()); //use column type
138138
Assert.AreEqual(20F, result);
139139

140-
if (TestDialect.SupportsHavingWithoutGroupBy)
141-
{
142-
result = s.CreateQuery("select max(a.BodyWeight) from Animal a having max(a.BodyWeight)>0").UniqueResult();
143-
Assert.AreEqual(typeof(float), result.GetType()); //use column type
144-
Assert.AreEqual(20F, result);
145-
}
140+
if (TestDialect.SupportsHavingWithoutGroupBy)
141+
{
142+
result = s.CreateQuery("select max(a.BodyWeight) from Animal a having max(a.BodyWeight)>0").UniqueResult();
143+
Assert.AreEqual(typeof(float), result.GetType()); //use column type
144+
Assert.AreEqual(20F, result);
145+
}
146146
}
147147
}
148148

@@ -163,12 +163,12 @@ public void AggregateMin()
163163
Assert.AreEqual(typeof(float), result.GetType()); //use column type
164164
Assert.AreEqual(10F, result);
165165

166-
if (TestDialect.SupportsHavingWithoutGroupBy)
167-
{
168-
result = s.CreateQuery("select min(a.BodyWeight) from Animal a having min(a.BodyWeight)>0").UniqueResult();
169-
Assert.AreEqual(typeof(float), result.GetType()); //use column type
170-
Assert.AreEqual(10F, result);
171-
}
166+
if (TestDialect.SupportsHavingWithoutGroupBy)
167+
{
168+
result = s.CreateQuery("select min(a.BodyWeight) from Animal a having min(a.BodyWeight)>0").UniqueResult();
169+
Assert.AreEqual(typeof(float), result.GetType()); //use column type
170+
Assert.AreEqual(10F, result);
171+
}
172172
}
173173
}
174174

@@ -189,12 +189,12 @@ public void AggregateSum()
189189
Assert.AreEqual(typeof(double), result.GetType());
190190
Assert.AreEqual(30D, result);
191191

192-
if (TestDialect.SupportsHavingWithoutGroupBy)
193-
{
194-
result = s.CreateQuery("select sum(a.BodyWeight) from Animal a having sum(a.BodyWeight)>0").UniqueResult();
195-
Assert.AreEqual(typeof(double), result.GetType());
196-
Assert.AreEqual(30D, result);
197-
}
192+
if (TestDialect.SupportsHavingWithoutGroupBy)
193+
{
194+
result = s.CreateQuery("select sum(a.BodyWeight) from Animal a having sum(a.BodyWeight)>0").UniqueResult();
195+
Assert.AreEqual(typeof(double), result.GetType());
196+
Assert.AreEqual(30D, result);
197+
}
198198
}
199199
}
200200

@@ -261,9 +261,9 @@ public void SubStringTwoParameters()
261261
{
262262
hql = "from Animal a where substring(concat(a.Description, ?), :start) = 'deffoo'";
263263
result = (Animal) s.CreateQuery(hql)
264-
.SetParameter(0, "foo")
265-
.SetParameter("start", 4)
266-
.UniqueResult();
264+
.SetParameter(0, "foo")
265+
.SetParameter("start", 4)
266+
.UniqueResult();
267267
Assert.AreEqual("abcdef", result.Description);
268268
}
269269
}

src/NHibernate.Test/Linq/ByMethod/GetValueOrDefaultTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
using System.Linq;
2+
using NHibernate.Dialect;
23
using NUnit.Framework;
34

45
namespace NHibernate.Test.Linq.ByMethod
56
{
67
[TestFixture]
78
public class GetValueOrDefaultTests : LinqTestCase
89
{
10+
protected override bool AppliesTo(Dialect.Dialect dialect)
11+
{
12+
// It seems that SQLite has a nasty bug with coalesce
13+
14+
// Following query does not work
15+
// SELECT order0_.*
16+
// FROM Orders order0_
17+
// WHERE coalesce(order0_.Freight, 0) > @p0;
18+
19+
// And this one works
20+
// SELECT order0_.*
21+
// FROM Orders order0_
22+
// WHERE cast(coalesce(order0_.Freight, 0) as NUMERIC) > @p0;
23+
24+
if (dialect is SQLiteDialect)
25+
return false;
26+
return base.AppliesTo(dialect);
27+
}
28+
929
[Test]
1030
public void CoalesceInWhere()
1131
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NHibernate.Test.MappingByCode.IntegrationTests.NH3140
5+
{
6+
public class Foo
7+
{
8+
public virtual Guid Id { get; set; }
9+
public virtual ICollection<Bar> Bars { get; set; }
10+
}
11+
12+
public class Bar
13+
{
14+
public virtual Guid Id { get; set; }
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Linq;
2+
using NHibernate.Cfg.MappingSchema;
3+
using NHibernate.Mapping.ByCode;
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.MappingByCode.IntegrationTests.NH3140
7+
{
8+
public class Fixture
9+
{
10+
[TestCase("DifferentFromBar")]
11+
[TestCase("Bar")]
12+
public void ExplicitColumnNameIsAlwaysMapped(string columnName)
13+
{
14+
var mapper = new ModelMapper();
15+
mapper.Class<Foo>(cm => cm.Bag(x => x.Bars,
16+
bpm => { },
17+
cer => cer.ManyToMany(mtmm => mtmm.Column(columnName))));
18+
var mapping = mapper.CompileMappingFor(new[] { typeof(Foo), typeof(Bar) });
19+
var hbmClass = mapping.RootClasses.Single(x => x.Name == "Foo");
20+
var hbmBag = hbmClass.Properties.OfType<HbmBag>().Single();
21+
var hbmManyToMany = (HbmManyToMany)hbmBag.ElementRelationship;
22+
Assert.AreEqual(columnName, hbmManyToMany.column);
23+
}
24+
}
25+
}

src/NHibernate.Test/NHSpecificTest/NH1857/FullJoinTest.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using NHibernate.Dialect;
34
using NUnit.Framework;
45

56
namespace NHibernate.Test.NHSpecificTest.NH1857
@@ -9,8 +10,8 @@ public class FullJoinTest : BugTestCase
910
{
1011
protected override void OnSetUp()
1112
{
12-
base.OnSetUp();
13-
using (ISession session = OpenSession())
13+
using (var session = OpenSession())
14+
using (var transaction = session.BeginTransaction())
1415
{
1516
var e1 = new Employee(1, "Employee1", new DateTime(1995, 1, 1));
1617
var e2 = new Employee(2, "Employee2", new DateTime(2007, 8, 1));
@@ -26,35 +27,42 @@ protected override void OnSetUp()
2627
session.SaveOrUpdate(e2);
2728
session.SaveOrUpdate(e3);
2829

29-
session.Flush();
30+
transaction.Commit();
3031
}
3132
}
3233

3334
protected override void OnTearDown()
3435
{
35-
base.OnTearDown();
36-
using (ISession session = OpenSession())
37-
using (ITransaction t = session.BeginTransaction())
36+
using (var session = OpenSession())
37+
using (var transaction = session.BeginTransaction())
3838
{
3939
session.CreateQuery("delete from Employee").ExecuteUpdate();
4040
session.CreateQuery("delete from Department").ExecuteUpdate();
41-
t.Commit();
41+
transaction.Commit();
4242
}
4343
}
4444

4545
protected override bool AppliesTo(Dialect.Dialect dialect)
4646
{
47-
return TestDialect.GetTestDialect(dialect).SupportsFullJoin;
47+
if (dialect is MySQLDialect)
48+
return false;
49+
if (dialect is InformixDialect)
50+
return false;
51+
if (dialect is SQLiteDialect)
52+
return false;
53+
54+
return true;
4855
}
4956

5057
[Test]
5158
public void TestFullJoin()
5259
{
53-
using (ISession s = OpenSession())
60+
using (var session = OpenSession())
61+
using (session.BeginTransaction())
5462
{
55-
IQuery q = s.CreateQuery("from Employee as e full join e.Department");
63+
var q = session.CreateQuery("from Employee as e full join e.Department");
5664

57-
IList result = q.List();
65+
var result = q.List();
5866

5967
Assert.AreEqual(3, result.Count);
6068
}

src/NHibernate.Test/NHSpecificTest/NH2858/DomainClass.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)