|
From: <fab...@us...> - 2010-07-21 06:37:41
|
Revision: 5028
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5028&view=rev
Author: fabiomaulo
Date: 2010-07-21 06:37:34 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Fix NH-1891
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:11:15 UTC (rev 5027)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:37:34 UTC (rev 5028)
@@ -95,6 +95,7 @@
IEnumerator<string> tokensEnum = tokens.GetEnumerator();
bool hasMore = tokensEnum.MoveNext();
string nextToken = hasMore ? tokensEnum.Current : null;
+ string lastToken = string.Empty;
while (hasMore)
{
string token = nextToken;
@@ -139,7 +140,7 @@
isOpenQuote = false;
}
- if (isOpenQuote && !inFromClause)
+ if (isOpenQuote && !inFromClause && !lastToken.EndsWith("."))
{
result.Append(placeholder).Append('.');
}
@@ -201,6 +202,7 @@
{
inFromClause = false;
}
+ lastToken = token;
}
return result.ToString();
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/A.cs 2010-07-21 06:37:34 UTC (rev 5028)
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1891
+{
+ public class A
+ {
+ public virtual Guid Id { get; set; }
+ public virtual int FormulaCount { get; set; }
+ public virtual string FormulaConstraint { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/B.cs 2010-07-21 06:37:34 UTC (rev 5028)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1891
+{
+ public class B
+ {
+ public virtual Guid Id { get; set; }
+ public virtual string Name { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/Fixture.cs 2010-07-21 06:37:34 UTC (rev 5028)
@@ -0,0 +1,56 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1891
+{
+ [TestFixture]
+ public class Fixture : TestCase
+ {
+ protected override System.Collections.IList Mappings
+ {
+ get { return new string[] { "NHSpecificTest.NH1891.FormulaEscaping.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession s = OpenSession())
+ {
+ s.Delete("from B");
+ s.Flush();
+ s.Delete("from A");
+ s.Flush();
+ }
+ }
+
+ [Test]
+ public void FormulaEscaping()
+ {
+ string name = "Test";
+
+ B b = new B();
+ b.Name = name;
+
+ A a = new A();
+ a.FormulaConstraint = name;
+
+ ISession s = OpenSession();
+
+ s.Save(b);
+ s.Save(a);
+ s.Flush();
+ s.Close();
+
+ s = OpenSession();
+
+ a = s.Get<A>(a.Id);
+
+ Assert.AreEqual(1, a.FormulaCount);
+
+ s.Close();
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1891/FormulaEscaping.hbm.xml 2010-07-21 06:37:34 UTC (rev 5028)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1891">
+ <class name="A" table="a" lazy="false">
+ <id name="Id" column="id">
+ <generator class="guid.comb" />
+ </id>
+ <property name="FormulaCount" formula="(select count(*) from b where b.`Name` = FormulaConstraint)" type="Int32" />
+ <property name="FormulaConstraint" />
+ </class>
+
+ <class name="B" table="b">
+ <id name="Id" column="id">
+ <generator class="guid.comb" />
+ </id>
+ <property name="Name" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:11:15 UTC (rev 5027)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:37:34 UTC (rev 5028)
@@ -448,6 +448,9 @@
<Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Employee.cs" />
<Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Fixture.cs" />
<Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Money.cs" />
+ <Compile Include="NHSpecificTest\NH1891\A.cs" />
+ <Compile Include="NHSpecificTest\NH1891\B.cs" />
+ <Compile Include="NHSpecificTest\NH1891\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2061\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2061\Model.cs" />
<Compile Include="NHSpecificTest\NH2069\Fixture.cs" />
@@ -2192,6 +2195,7 @@
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1891\FormulaEscaping.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|