From: <fab...@us...> - 2009-10-14 16:19:29
|
Revision: 4742 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4742&view=rev Author: fabiomaulo Date: 2009-10-14 16:19:19 +0000 (Wed, 14 Oct 2009) Log Message: ----------- Fix NH-1992 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs 2009-10-08 17:50:58 UTC (rev 4741) +++ branches/2.1.x/nhibernate/src/NHibernate/AdoNet/Util/BasicFormatter.cs 2009-10-14 16:19:19 UTC (rev 4742) @@ -79,6 +79,7 @@ private bool afterInsert; private bool afterOn; private bool beginLine = true; + private bool endCommandFound; private int indent = 1; private int inFunction; @@ -186,6 +187,7 @@ { Out(); indent = 1; + endCommandFound = true; Newline(); } @@ -285,6 +287,7 @@ { afterInsert = true; } + endCommandFound = false; } private void Select() @@ -296,6 +299,7 @@ afterByOrFromOrSelects.Insert(afterByOrFromOrSelects.Count, afterByOrSetOrFromOrSelect); parensSinceSelect = 0; afterByOrSetOrFromOrSelect = true; + endCommandFound = false; } private void Out() @@ -353,6 +357,11 @@ private void CloseParen() { + if (endCommandFound) + { + Out(); + return; + } parensSinceSelect--; if (parensSinceSelect < 0) { @@ -384,6 +393,11 @@ private void OpenParen() { + if(endCommandFound) + { + Out(); + return; + } if (IsFunctionName(lastToken) || inFunction > 0) { inFunction++; Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-08 17:50:58 UTC (rev 4741) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-14 16:19:19 UTC (rev 4742) @@ -1405,6 +1405,7 @@ <Compile Include="UserCollection\User.cs" /> <Compile Include="UserCollection\UserCollectionTypeTest.cs" /> <Compile Include="UtilityTest\AssemblyQualifiedTypeNameFixture.cs" /> + <Compile Include="UtilityTest\BasicFormatterFixture.cs" /> <Compile Include="UtilityTest\IdentityMapFixture.cs" /> <Compile Include="UtilityTest\IdentityMapSequencedFixture.cs" /> <Compile Include="UtilityTest\JoinedEnumerableFixture.cs" /> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/UtilityTest/BasicFormatterFixture.cs 2009-10-14 16:19:19 UTC (rev 4742) @@ -0,0 +1,23 @@ +using NHibernate.AdoNet.Util; +using NUnit.Framework; + +namespace NHibernate.Test.UtilityTest +{ + [TestFixture] + public class BasicFormatterFixture + { + [Test] + public void StringWithNestedDelimiters() + { + string formattedSql = null; + IFormatter formatter = new BasicFormatter(); + string sql = @"INSERT INTO Table (Name, id) VALUES (@p0, @p1); @p0 = 'a'(b', @p1 = 1"; + Assert.DoesNotThrow(() => formattedSql = formatter.Format(sql)); + Assert.That(formattedSql, Text.Contains("'a'(b'")); + + sql = @"UPDATE Table SET Column = @p0;@p0 = '(')'"; + Assert.DoesNotThrow(() => formattedSql = formatter.Format(sql)); + Assert.That(formattedSql, Text.Contains("'(')'")); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |