|
From: <fab...@us...> - 2010-07-21 06:11:23
|
Revision: 5027
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5027&view=rev
Author: fabiomaulo
Date: 2010-07-21 06:11:15 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Fix NH-2242
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/NH2242/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-20 21:23:32 UTC (rev 5026)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/Template.cs 2010-07-21 06:11:15 UTC (rev 5027)
@@ -139,7 +139,7 @@
isOpenQuote = false;
}
- if (isOpenQuote)
+ if (isOpenQuote && !inFromClause)
{
result.Append(placeholder).Append('.');
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/EscapedFormulaDomainClass.cs 2010-07-21 06:11:15 UTC (rev 5027)
@@ -0,0 +1,21 @@
+namespace NHibernate.Test.NHSpecificTest.NH2242
+{
+ public class EscapedFormulaDomainClass
+ {
+ private int id;
+
+ private int formula;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public int Formula
+ {
+ get { return formula; }
+ set { formula = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/FormulaTest.cs 2010-07-21 06:11:15 UTC (rev 5027)
@@ -0,0 +1,69 @@
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH2242
+{
+ [TestFixture]
+ public class FormulaTest : BugTestCase
+ {
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect as MsSql2005Dialect != null;
+ }
+
+ [Test]
+ public void FormulaOfEscapedDomainClassShouldBeRetrievedCorrectly()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var entity = new EscapedFormulaDomainClass();
+ entity.Id = 1;
+ session.Save(entity);
+
+ transaction.Commit();
+ }
+
+ session.Clear();
+
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var entity = session.Get<EscapedFormulaDomainClass>(1);
+
+ Assert.AreEqual(1, entity.Formula);
+ session.Delete(entity);
+
+ transaction.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void FormulaOfUnescapedDomainClassShouldBeRetrievedCorrectly()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var entity = new UnescapedFormulaDomainClass();
+ entity.Id = 1;
+ session.Save(entity);
+
+ transaction.Commit();
+ }
+
+ session.Clear();
+
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ var entity = session.Get<UnescapedFormulaDomainClass>(1);
+
+ Assert.AreEqual(1, entity.Formula);
+ session.Delete(entity);
+ transaction.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/Mappings.hbm.xml 2010-07-21 06:11:15 UTC (rev 5027)
@@ -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.NH2242" default-access="field.camelcase"
+ default-lazy="false">
+ <class name="EscapedFormulaDomainClass">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ <property name="Formula" formula="(SELECT COUNT(*) FROM [EscapedFormulaDomainClass])" />
+ </class>
+ <class name="UnescapedFormulaDomainClass">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ <property name="Formula" formula="(SELECT COUNT(*) FROM UnescapedFormulaDomainClass)" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2242/UnescapedFormulaDomainClass.cs 2010-07-21 06:11:15 UTC (rev 5027)
@@ -0,0 +1,21 @@
+namespace NHibernate.Test.NHSpecificTest.NH2242
+{
+ public class UnescapedFormulaDomainClass
+ {
+ private int id;
+
+ private int formula;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public int Formula
+ {
+ get { return formula; }
+ set { formula = value; }
+ }
+ }
+}
\ 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-20 21:23:32 UTC (rev 5026)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 06:11:15 UTC (rev 5027)
@@ -752,6 +752,9 @@
<Compile Include="NHSpecificTest\NH2230\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2234\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2234\MyType.cs" />
+ <Compile Include="NHSpecificTest\NH2242\EscapedFormulaDomainClass.cs" />
+ <Compile Include="NHSpecificTest\NH2242\FormulaTest.cs" />
+ <Compile Include="NHSpecificTest\NH2242\UnescapedFormulaDomainClass.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
<Compile Include="NHSpecificTest\NH473\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Parent.cs" />
@@ -2189,6 +2192,7 @@
<EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" />
<EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|