Skip to content

Commit 8c93e6f

Browse files
committed
Fixing NH 2044 & NH 2045
SVN: trunk@4910
1 parent e3ff1d1 commit 8c93e6f

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
3+
namespace NHibernate.Test.NHSpecificTest.NH2044
4+
{
5+
public class DomainClass
6+
{
7+
private char symbol;
8+
private int id;
9+
10+
public int Id
11+
{
12+
get { return id; }
13+
set { id = value; }
14+
}
15+
16+
public char Symbol
17+
{
18+
get { return symbol; }
19+
set { symbol = value; }
20+
}
21+
}
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
3+
namespace="NHibernate.Test.NHSpecificTest.NH2044" default-access="field.camelcase"
4+
default-lazy="false">
5+
<class name="DomainClass">
6+
<id name="Id">
7+
<generator class="assigned" />
8+
</id>
9+
<property name="Symbol" type="Char"/>
10+
</class>
11+
</hibernate-mapping>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using NHibernate.Dialect;
6+
using NUnit.Framework;
7+
8+
namespace NHibernate.Test.NHSpecificTest.NH2044
9+
{
10+
[TestFixture]
11+
public class SampleTest : BugTestCase
12+
{
13+
protected override void OnSetUp()
14+
{
15+
base.OnSetUp();
16+
using (ISession session = this.OpenSession())
17+
{
18+
DomainClass entity = new DomainClass();
19+
entity.Id = 1;
20+
entity.Symbol = 'S';
21+
session.Save(entity);
22+
session.Flush();
23+
}
24+
}
25+
26+
protected override void OnTearDown()
27+
{
28+
base.OnTearDown();
29+
using (ISession session = this.OpenSession())
30+
{
31+
string hql = "from DomainClass";
32+
session.Delete(hql);
33+
session.Flush();
34+
}
35+
}
36+
37+
38+
[Test]
39+
public void IgnoreCaseShouldWorkWithCharCorrectly()
40+
{
41+
using (ISession session = this.OpenSession())
42+
{
43+
ICriteria criteria = session.CreateCriteria(typeof(DomainClass), "domain");
44+
criteria.Add(NHibernate.Criterion.Expression.Eq("Symbol", 's').IgnoreCase());
45+
IList<DomainClass> list = criteria.List<DomainClass>();
46+
47+
Assert.AreEqual(1, list.Count);
48+
49+
}
50+
}
51+
}
52+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@
658658
<Compile Include="NHSpecificTest\NH1938\Model.cs" />
659659
<Compile Include="NHSpecificTest\NH1939\AuxType.cs" />
660660
<Compile Include="NHSpecificTest\NH1939\Fixture.cs" />
661+
<Compile Include="NHSpecificTest\NH2044\DomainClass.cs" />
662+
<Compile Include="NHSpecificTest\NH2044\SampleTest.cs" />
661663
<Compile Include="NHSpecificTest\NH2055\AuxType.cs" />
662664
<Compile Include="NHSpecificTest\NH2055\Fixture.cs" />
663665
<Compile Include="NHSpecificTest\NH2057\Fixture.cs" />
@@ -2098,6 +2100,7 @@
20982100
<EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" />
20992101
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
21002102
<Content Include="DynamicEntity\package.html" />
2103+
<EmbeddedResource Include="NHSpecificTest\NH2044\Mappings.hbm.xml" />
21012104
<EmbeddedResource Include="NHSpecificTest\NH2030\Mappings.hbm.xml" />
21022105
<EmbeddedResource Include="Linq\Mappings\Patient.hbm.xml" />
21032106
<EmbeddedResource Include="NHSpecificTest\NH2055\Mappings.hbm.xml" />

src/NHibernate/Type/AbstractCharType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override System.Type ReturnedClass
4848

4949
public override void Set(IDbCommand cmd, object value, int index)
5050
{
51-
((IDataParameter)cmd.Parameters[index]).Value = (char)value;
51+
((IDataParameter)cmd.Parameters[index]).Value = Convert.ToChar(value);
5252
}
5353

5454
public override string ObjectToSQLString(object value, Dialect.Dialect dialect)

0 commit comments

Comments
 (0)