|
From: <ric...@us...> - 2009-08-04 12:51:24
|
Revision: 4680
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4680&view=rev
Author: ricbrown
Date: 2009-08-04 12:51:17 +0000 (Tue, 04 Aug 2009)
Log Message:
-----------
Merge r4679 (Fix NH-1908)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs
Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:49:38 UTC (rev 4679)
+++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-08-04 12:51:17 UTC (rev 4680)
@@ -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]++;
+ }
}
}
}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2009-08-04 12:51:17 UTC (rev 4680)
@@ -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();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Mappings.hbm.xml 2009-08-04 12:51:17 UTC (rev 4680)
@@ -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: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2009-08-04 12:51:17 UTC (rev 4680)
@@ -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; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:49:38 UTC (rev 4679)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-08-04 12:51:17 UTC (rev 4680)
@@ -558,6 +558,8 @@
<Compile Include="NHSpecificTest\NH1899\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1907\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1907\MyType.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" />
@@ -1974,6 +1976,7 @@
<EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" />
<EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" />
<EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1908\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1898\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1907\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1899\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|