|
From: <dav...@us...> - 2009-07-26 15:07:47
|
Revision: 4657
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4657&view=rev
Author: davybrion
Date: 2009-07-26 15:07:33 +0000 (Sun, 26 Jul 2009)
Log Message:
-----------
applying patch from Armin Landscheidt to fix NH-1902
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Criterion/Example.cs
trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs
Modified: trunk/nhibernate/src/NHibernate/Criterion/Example.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-19 22:22:59 UTC (rev 4656)
+++ trunk/nhibernate/src/NHibernate/Criterion/Example.cs 2009-07-26 15:07:33 UTC (rev 4657)
@@ -481,7 +481,7 @@
{
bool isString = propertyValue is String;
crit = (_isLikeEnabled && isString) ?
- (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), escapeCharacter, _isIgnoreCaseEnabled) :
+ (ICriterion) new LikeExpression(propertyName, propertyValue.ToString(), _matchMode, escapeCharacter, _isIgnoreCaseEnabled) :
new SimpleExpression(propertyName, propertyValue, " = ", _isIgnoreCaseEnabled && isString);
}
else
Modified: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-19 22:22:59 UTC (rev 4656)
+++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2009-07-26 15:07:33 UTC (rev 4657)
@@ -42,6 +42,51 @@
}
[Test]
+ public void TestEnableLikeWithMatchmodeStart() {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction()) {
+ Componentizable master = GetMaster("hib", null, "open source1");
+ ICriteria crit = s.CreateCriteria(typeof(Componentizable));
+ Example ex = Example.Create(master).EnableLike(MatchMode.Start);
+ crit.Add(ex);
+ IList result = crit.List();
+ Assert.IsNotNull(result);
+ Assert.AreEqual(1, result.Count);
+ t.Commit();
+ }
+ }
+
+ [Test]
+ public void TestEnableLikeWithMatchmodeEnd() {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction()) {
+ Componentizable master = GetMaster("nate", null, "ORM tool1");
+ ICriteria crit = s.CreateCriteria(typeof(Componentizable));
+ Example ex = Example.Create(master).EnableLike(MatchMode.End);
+ crit.Add(ex);
+ IList result = crit.List();
+ Assert.IsNotNull(result);
+ Assert.AreEqual(1, result.Count);
+ t.Commit();
+ }
+ }
+
+ [Test]
+ public void TestEnableLikeWithMatchmodeAnywhere() {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction()) {
+ Componentizable master = GetMaster("bern", null, null);
+ ICriteria crit = s.CreateCriteria(typeof(Componentizable));
+ Example ex = Example.Create(master).EnableLike(MatchMode.Anywhere);
+ crit.Add(ex);
+ IList result = crit.List();
+ Assert.IsNotNull(result);
+ Assert.AreEqual(3, result.Count);
+ t.Commit();
+ }
+ }
+
+ [Test]
public void TestJunctionNotExpressionQBE()
{
using (ISession s = OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|