From: <ric...@us...> - 2009-08-04 12:49:55
|
Revision: 4679 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4679&view=rev Author: ricbrown Date: 2009-08-04 12:49:38 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Fix NH-1908 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-03 22:45:29 UTC (rev 4678) +++ branches/2.1.x/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -72,19 +72,13 @@ // NH Different behaviour NH-1776 // Analyze all named parameters declared after filters // in general all named parameters but depend on the complexity of the query (see sub query) - foreach (ParameterInfo entry in _namedParameters.Values) + RestoreOriginalParameterLocations(); + foreach (int filterParameterLocation in parameters.FilteredParameterLocations) { - int amountOfPush = 0; - foreach (int existingParameterLocation in parameters.FilteredParameterLocations) + foreach (ParameterInfo entry in _namedParameters.Values) { - // a parameter span, at least, one value; where span more than one all values are cosecutive - // the first position determines the position of the others values - if (entry.SqlLocations[0]+amountOfPush >= existingParameterLocation) - { - amountOfPush++; - } + entry.IncrementLocationAfterFilterLocation(filterParameterLocation); } - entry.IncrementLocation(amountOfPush); } } @@ -123,6 +117,14 @@ get { return _ordinalParameters.Length; } } + private void RestoreOriginalParameterLocations() + { + foreach (ParameterInfo entry in _namedParameters.Values) + { + entry.RestoreOriginalParameterLocations(); + } + } + private ParameterInfo GetOrdinalParameterInfo(int ordinalPosition) { // remember that ordinal parameters numbers are 1-based!!! @@ -169,15 +171,22 @@ public IType ExpectedType { get; private set; } - public void IncrementLocation(int amountOfPush) + public void RestoreOriginalParameterLocations() { - if(amountOfPush <= 0) + for (int i = 0; i < sqlLocations.Length; i++) { - return; // short cut + sqlLocations[i] = originalLocation[i]; } + } + + public void IncrementLocationAfterFilterLocation(int filterParameterLocation) + { for (int i = 0; i < sqlLocations.Length; i++) { - sqlLocations[i] = originalLocation[i] + amountOfPush; + if (sqlLocations[i] >= filterParameterLocation) + { + sqlLocations[i]++; + } } } } Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,35 @@ +using System; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + [TestFixture] + public class Fixture : BugTestCase + { + + [Test] + public void QueryPropertyInBothFilterAndQuery() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("validity") + .SetParameter("date", DateTime.Now); + + s.CreateQuery(@" + select + inv.ID + from + Invoice inv + join inv.Category cat with cat.ValidUntil > :now + left join cat.ParentCategory parentCat + where + inv.ID = :invId + and inv.Issued < :now + ") + .SetDateTime("now", DateTime.Now) + .SetInt32("invId", -999) + .List(); + } + } + } +} Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1908"> + + <class name="Category"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + <property name="ValidUntil" type="DateTime" /> + <many-to-one name="ParentCategory" column="CategoryId" class="Category" /> + <filter name="validity" condition="ValidUntil > :date" /> + </class> + + <class name="Invoice"> + <id name="ID" type="Int32"> + <generator class="hilo" /> + </id> + + <many-to-one name="Category" column="CategoryId" class="Category" /> + <property name="Issued" type="DateTime" /> + </class> + + <filter-def name="validity"> + <filter-param name="date" type="DateTime"/> + </filter-def> + +</hibernate-mapping> Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2009-08-04 12:49:38 UTC (rev 4679) @@ -0,0 +1,18 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1908 +{ + public class Category + { + public virtual int ID { get; private set; } + public virtual Category ParentCategory { get; set; } + public virtual DateTime ValidUntil { get; set; } + } + + public class Invoice + { + public virtual int ID { get; private set; } + public virtual DateTime Issued { get; set; } + public virtual Category Category { get; set; } + } +} Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-03 22:45:29 UTC (rev 4678) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:49:38 UTC (rev 4679) @@ -546,6 +546,8 @@ <Compile Include="NHSpecificTest\NH1899\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1907\MyType.cs" /> <Compile Include="NHSpecificTest\NH1907\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1908\Model.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -1956,6 +1958,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" /> <EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" /> <EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |