Skip to content

Commit 1814f91

Browse files
Add test for NH-2893
Test requires explicit execution due to use of Sybase SQL Anywhere with a customised driver. Unfortunately none the current CI databases have drivers where UseNamedPrefixInSql returns false. This is required to reproduce the issue. Databases reported with the issue are Pervasive PSQL, IBM DB2 and Informix - all with UseNamedPrefixInSql = false.
1 parent b6f8e8a commit 1814f91

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using NHibernate.Cfg.MappingSchema;
2+
using NHibernate.Criterion;
3+
using NHibernate.DomainModel.Northwind.Entities;
4+
using NHibernate.Mapping.ByCode;
5+
using NHibernate.Test.NHSpecificTest.NH1845;
6+
using NUnit.Framework;
7+
8+
namespace NHibernate.Test.NHSpecificTest.NH2893
9+
{
10+
public class Fixture : TestCaseMappingByCode
11+
{
12+
protected override HbmMapping GetMappings()
13+
{
14+
var mapper = new ModelMapper();
15+
mapper.Class<User>(rc =>
16+
{
17+
rc.Id(x => x.Id);
18+
rc.Property(x => x.Name, mapping => mapping.Length(256));
19+
});
20+
21+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
22+
}
23+
24+
protected override bool AppliesTo(Dialect.Dialect dialect)
25+
{
26+
return (dialect is Dialect.SybaseSQLAnywhere12Dialect);
27+
}
28+
29+
protected override void Configure(Cfg.Configuration configuration)
30+
{
31+
configuration.SetProperty("hbm2ddl.keywords", "auto-quote");
32+
}
33+
34+
protected override void OnSetUp()
35+
{
36+
base.OnSetUp();
37+
using (ISession session = OpenSession())
38+
using (ITransaction transaction = session.BeginTransaction())
39+
{
40+
var newUser = new User() { Id = 1000, Name = "Julian Maughan" };
41+
session.Save(newUser);
42+
transaction.Commit();
43+
}
44+
}
45+
46+
protected override void OnTearDown()
47+
{
48+
using (ISession session = OpenSession())
49+
using (ITransaction transaction = session.BeginTransaction())
50+
{
51+
session.CreateQuery("delete from User").ExecuteUpdate();
52+
transaction.Commit();
53+
}
54+
base.OnTearDown();
55+
}
56+
57+
[Test]
58+
[Explicit("Reproduces the issue only on Sybase SQL Anywhere with the driver configured with UseNamedPrefixInSql = false")]
59+
public void Test()
60+
{
61+
using (ISession session = OpenSession())
62+
using (ITransaction transaction = session.BeginTransaction())
63+
{
64+
var list = session
65+
.CreateCriteria<User>()
66+
.Add(Restrictions.InsensitiveLike("Name", "Julian", MatchMode.Anywhere))
67+
.List<User>();
68+
69+
Assert.That(list.Count, Is.EqualTo(1));
70+
Assert.That(list[0].Id, Is.EqualTo(1000));
71+
72+
transaction.Commit();
73+
}
74+
}
75+
}
76+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@
898898
<Compile Include="NHSpecificTest\NH2869\IsTrueInDbFalseInLocalGenerator.cs" />
899899
<Compile Include="NHSpecificTest\NH2869\MyLinqExtensions.cs" />
900900
<Compile Include="NHSpecificTest\NH2869\MyLinqToHqlGeneratorsRegistry.cs" />
901+
<Compile Include="NHSpecificTest\NH2893\Fixture.cs" />
901902
<Compile Include="NHSpecificTest\NH941\Domain.cs" />
902903
<Compile Include="NHSpecificTest\NH941\Fixture.cs" />
903904
<Compile Include="NHSpecificTest\NH941\FixtureUsingList.cs" />

0 commit comments

Comments
 (0)