|
From: <fab...@us...> - 2009-07-04 05:07:04
|
Revision: 4568
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4568&view=rev
Author: fabiomaulo
Date: 2009-07-04 05:06:59 +0000 (Sat, 04 Jul 2009)
Log Message:
-----------
Merge r4567 (fix NH-1864)
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/NH1864/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs
Modified: trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-07-04 05:03:54 UTC (rev 4567)
+++ trunk/nhibernate/src/NHibernate/Param/ParameterTranslationsImpl.cs 2009-07-04 05:06:59 UTC (rev 4568)
@@ -69,18 +69,22 @@
public void AdjustNamedParameterLocationsForQueryParameters(QueryParameters parameters)
{
- foreach (int existingParameterLocation in parameters.FilteredParameterLocations)
+ // 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
+ foreach (ParameterInfo entry in _namedParameters.Values)
{
- foreach (ParameterInfo entry in _namedParameters.Values)
+ int amountOfPush = 0;
+ foreach (int existingParameterLocation in parameters.FilteredParameterLocations)
{
- for (int index = 0; index < entry.SqlLocations.Length; index++)
+ // 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] >= existingParameterLocation)
{
- if (entry.SqlLocations[index] >= existingParameterLocation)
- {
- entry.IncrementLocation(index);
- }
+ amountOfPush++;
}
}
+ entry.IncrementLocation(amountOfPush);
}
}
@@ -165,9 +169,16 @@
public IType ExpectedType { get; private set; }
- public void IncrementLocation(int index)
+ public void IncrementLocation(int amountOfPush)
{
- sqlLocations[index] = originalLocation[index] + 1;
+ if(amountOfPush <= 0)
+ {
+ return; // short cut
+ }
+ for (int i = 0; i < sqlLocations.Length; i++)
+ {
+ sqlLocations[i] = originalLocation[i] + amountOfPush;
+ }
}
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Fixture.cs 2009-07-04 05:06:59 UTC (rev 4568)
@@ -0,0 +1,50 @@
+using System;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1864
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void ExecuteQuery(Action<ISession> sessionModifier)
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ sessionModifier(session);
+ session.CreateQuery(
+ @"select cat
+ from Invoice inv, Category cat
+ where cat.ValidUntil = :now and inv.Foo = :foo
+ ")
+ .SetInt32("foo", 42).SetDateTime("now", DateTime.Now).List();
+
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void Bug()
+ {
+ Assert.DoesNotThrow(() => ExecuteQuery(s=> s.EnableFilter("validity").SetParameter("date", DateTime.Now)));
+ }
+
+ [Test]
+ public void FilterOnOffOn()
+ {
+ Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now)));
+ Assert.DoesNotThrow(() => ExecuteQuery(s => { }));
+ Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now)));
+ }
+
+ [Test]
+ public void FilterQueryTwice()
+ {
+ Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now)));
+ Assert.DoesNotThrow(() => ExecuteQuery(s => s.EnableFilter("validity").SetParameter("date", DateTime.Now)));
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Mappings.hbm.xml 2009-07-04 05:06:59 UTC (rev 4568)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1864">
+
+ <class name="Category">
+ <id name="ID" type="Int32">
+ <generator class="hilo" />
+ </id>
+ <property name="ValidUntil" type="DateTime" />
+ <filter name="validity" condition="ValidUntil > :date" />
+ </class>
+
+ <class name="Invoice">
+ <id name="ID" type="Int32">
+ <generator class="hilo" />
+ </id>
+ <property name="Foo" type="Int32" />
+ <property name="ValidUntil" type="DateTime" />
+ <filter name="validity" condition="ValidUntil > :date" />
+ </class>
+
+ <filter-def name="validity">
+ <filter-param name="date" type="DateTime"/>
+ </filter-def>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1864/Model.cs 2009-07-04 05:06:59 UTC (rev 4568)
@@ -0,0 +1,17 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1864
+{
+ public class Category
+ {
+ public virtual int ID { get; private set; }
+ public virtual DateTime ValidUntil { get; set; }
+ }
+
+ public class Invoice
+ {
+ public virtual int ID { get; private set; }
+ public virtual DateTime ValidUntil { get; set; }
+ public virtual int Foo { get; set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 05:03:54 UTC (rev 4567)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 05:06:59 UTC (rev 4568)
@@ -533,6 +533,8 @@
<Compile Include="NHSpecificTest\NH1849\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1850\Customer.cs" />
<Compile Include="NHSpecificTest\NH1850\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1864\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1864\Model.cs" />
<Compile Include="NHSpecificTest\NH473\Child.cs" />
<Compile Include="NHSpecificTest\NH473\Fixture.cs" />
<Compile Include="NHSpecificTest\NH473\Parent.cs" />
@@ -1944,6 +1946,7 @@
<EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" />
<EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1864\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1850\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1192\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|