http://jira.nhibernate.org/browse/NH"Create New Issue"

Welcome to the club!!

2008/10/22 Jason Meckley <[EMAIL PROTECTED]>

>
> took most of the day, but we got there!
>
> after the build was successful I copied this over to my Foo paging
> spike. with the addition of NHibernate.ProxyGenerators I was able to
> get it working!
>
> I have a patch, but don't see where I can upload to this group
> (probally can't). This is my first patch to NH and I'm not sure where
> to submit it.  I see JIRA mentioned alot, but I'm not familiar with
> it. since the patch is a simple one I'll post the text here.
>
> Index: nhibernate/src/NHibernate.Test/DialectTest/
> SQLiteDialectFixture.cs
> ===================================================================
> --- nhibernate/src/NHibernate.Test/DialectTest/SQLiteDialectFixture.cs
> (revision 3871)
> +++ nhibernate/src/NHibernate.Test/DialectTest/SQLiteDialectFixture.cs
> (working copy)
> @@ -28,7 +28,7 @@
>         {
>             SqlString sql = new SqlString("SELECT id, name, email
> FROM Users");
>             SqlString s = dialect.GetLimitString(sql, 5, 10);
> -            Assert.AreEqual("SELECT id, name, email FROM Users limit
> 10, 5", s.ToString());
> +            Assert.AreEqual("SELECT id, name, email FROM Users limit
> 10 offset 5", s.ToString());
>         }
>
>         [Test]
> Index: nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs
> ===================================================================
> --- nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs  (revision 3871)
> +++ nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs  (working copy)
> @@ -183,7 +183,7 @@
>
>                        if (offset > 0)
>                        {
> -                               pagingBuilder.Add(", ");
> +                               pagingBuilder.Add(" offset ");
>                                pagingBuilder.Add(offset.ToString());
>                         }
>
>
>
>
> On Oct 22, 2:09 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > You probably need to update the nant version that you have.
> > Use the daily build, not the beta
> >
> > On Wed, Oct 22, 2008 at 7:34 PM, Jason Meckley <[EMAIL PROTECTED]
> >wrote:
> >
> >
> >
> > > downloaded the source, went to compile got erro "nh needs 3.5"
> > > installed 3.5 framework. confirmed it installed by checking C:\WINDOWS
> > > \Microsoft.NET\Framework\v3.5 exists. it does.
> > > attempted to compile again. same error. added -t:net-3.5 to the build
> > > command
> > > "C:\program files\nant\nant-0.86-beta1\bin\nant" -t:net-3.5 -
> > > D:project.config=release clean build >output-release-build.log
> > > PAUSE
> >
> > > then I got another error:
> > > C:\Documents and Settings\jmeckley\My Documents\Visual Studio
> > > 2005\Projects\Nhibernate\nhibernate>"C:\program files\nant\nant-0.86-
> > > beta1\bin\nant" -t:net-3.5 -D:project.config=release clean build
> > > 1>output-release-build.log
> > > Microsoft .NET Framework 3.5 (net-3.5) is not installed, or not
> > > correctly configured.
> >
> > >    Object reference not set to an instance of an object.
> >
> > > C:\Documents and Settings\jmeckley\My Documents\Visual Studio
> > > 2005\Projects\Nhibernate\nhibernate>PAUSE
> > > Press any key to continue . . .
> >
> > > The build script fails at line 110 in default.build (target is check-
> > > framework-version). is there a way to point ${framework::get-target-
> > > framework()} to 3.5 instead of 2.0?
> >
> > > besides the build problem I updated 2 files (sqlitedialect and
> > > sqlitedialectfixture to use offset instead of a comma) even if I
> > > submit the patch before testing. I still need the binary.  the current
> > > binary came from Rhino.Tools.
> >
> > > Thanks for sticking with me on this.
> > > jason
> >
> > > On Oct 22, 10:55 am, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > > > I think that that would be best, can you create a patch + tests for
> this?
> >
> > > > On Wed, Oct 22, 2008 at 3:25 PM, Jason Meckley <
> [EMAIL PROTECTED]
> > > >wrote:
> >
> > > > > PagingWithNhibernateSpec.Should_get_foos_01_through_10
> > > > > NHibernate: SELECT this_.Id as Id0_0_ FROM Foo this_ ORDER BY
> this_.Id
> > > > > asc limit 10; @p0 = '10'
> >
> > > > > PagingWithNhibernateSpec.Should_get_foos_11_through_20
> > > > > NHibernate: SELECT this_.Id as Id0_0_ FROM Foo this_ ORDER BY
> this_.Id
> > > > > asc limit 10, 10; @p0 = '10', @p1 = '10'
> >
> > > > > PagingWithNhibernateSpec.Should_get_foos_21_through_30
> > > > > NHibernate: SELECT this_.Id as Id0_0_ FROM Foo this_ ORDER BY
> this_.Id
> > > > > asc limit 10, 20; @p0 = '20', @p1 = '10'
> >
> > > > > PagingWithNhibernateSpec.Should_get_foos_31_through_40
> > > > > NHibernate: SELECT this_.Id as Id0_0_ FROM Foo this_ ORDER BY
> this_.Id
> > > > > asc limit 10, 30; @p0 = '30', @p1 = '10'
> >
> > > > > PagingWithNhibernateSpec.Should_get_foos_41_through_50
> > > > > NHibernate: SELECT this_.Id as Id0_0_ FROM Foo this_ ORDER BY
> this_.Id
> > > > > asc limit 10, 40; @p0 = '40', @p1 = '10'
> >
> > > > > I also found this posthttp://
> sqlite.phxsoftware.com/forums/t/569.aspx
> > > > > which describes the same problem with the raw SqLite. If I follow
> this
> > > > > correctly the syntax is backwards.
> >
> > > > > And this came straight from the SqLite documentation
> > > > >http://www.sqlite.org/lang_select.html
> > > > > "The LIMIT clause places an upper bound on the number of rows
> returned
> > > > > in the result. A negative LIMIT indicates no upper bound. The
> optional
> > > > > OFFSET following LIMIT specifies how many rows to skip at the
> > > > > beginning of the result set. In a compound query, the LIMIT clause
> may
> > > > > only appear on the final SELECT statement. The limit is applied to
> the
> > > > > entire query not to the individual SELECT statement to which it is
> > > > > attached. Note that if the OFFSET keyword is used in the LIMIT
> clause,
> > > > > then the limit is the first number and the offset is the second
> > > > > number. If a comma is used instead of the OFFSET keyword, then the
> > > > > offset is the first number and the limit is the second number. This
> > > > > seeming contradition is intentional - it maximizes compatibility
> with
> > > > > legacy SQL database systems."
> >
> > > > > so if this is true, should the Limit and Offset keywords be used to
> > > > > create the sql statement and remove confusion about the parameters?
> >
> > > > > On Oct 22, 6:23 am, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > > > > > Can you show the generated SQL?
> >
> > > > > > On Wed, Oct 22, 2008 at 4:04 AM, Jason Meckley <
> > > [EMAIL PROTECTED]
> > > > > >wrote:
> >
> > > > > > > I updated my criteria to include order.
> >
> > > > > > > private IList<Foo> GetResultsStartingAt(int firstResult)
> > > > > > > {
> > > > > > >    return session
> > > > > > >        .CreateCriteria(typeof (Foo))
> > > > > > >         .AddOrder(Order.Asc("id"))
> > > > > > >         .SetFirstResult(firstResult)
> > > > > > >        .SetMaxResults(PAGE_SIZE)
> > > > > > >        .List<Foo>();
> > > > > > > }
> >
> > > > > > > but the results are the same.
> > > > > > > the 1st 2 tests passs
> > > > > > > the last 2 fail.
> >
> > > > > > > the test fail with the respective messages
> > > > > > > Expected 21 was Actually 11
> > > > > > > Expected 31 was Actually 11
> >
> > > > > > > which looks like it's pulling the 2nd page of results instead
> of
> > > the
> > > > > > > 3rd/4th respectively.
> >
> > > > > > > If it makes a difference I'm using a SqLite in-memory database
> for
> > > > > > > this test. Could this be a possible bug with the driver?
> >
> > > > > > > On Oct 21, 9:46 pm, Jason Meckley <[EMAIL PROTECTED]>
> wrote:
> > > > > > > > interesting... I assumed that a default order (PK) would be
> used
> > > if
> > > > > no
> > > > > > > > other sort was applied.  I will add sorting to the tests
> above
> > > and
> > > > > see
> > > > > > > > how that effects it.
> >
> > > > > > > > On Oct 21, 9:23 pm, "Ayende Rahien" <[EMAIL PROTECTED]>
> wrote:
> >
> > > > > > > > > Unless you specify order, the DB is free to choose whatever
> > > order
> > > > > it
> > > > > > > likes.Let
> > > > > > > > > us take this:
> >
> > > > > > > > > select top 10 * from Foo
> >
> > > > > > > > > The DB is free to return completely different result sets
> for
> > > this
> > > > > > > query if
> > > > > > > > > you execute it twice
> >
> > > > > > > > > On Wed, Oct 22, 2008 at 3:16 AM, Jason Meckley <
> > > > > [EMAIL PROTECTED]
> > > > > > > >wrote:
> >
> > > > > > > > > > I don't follow. What do you mean "orders may be
> > > indeterministic"?
> >
> > > > > > > > > > On Oct 21, 5:02 pm, "Tuna Toksöz" <[EMAIL PROTECTED]>
> wrote:
> > > > > > > > > > > The orders may be indeterministic
> >
> > > > > > > > > > > On Tue, Oct 21, 2008 at 11:58 PM, Jason Meckley <
> > > > > > > [EMAIL PROTECTED]
> > > > > > > > > > >wrote:
> >
> > > > > > > > > > > > I'm having a difficult time understanding page,
> > > specifically
> > > > > > > > > > > > SetFirstResult() and SetMaxResults()
> >
> > > > > > > > > > > > from what I read on different posts SetFirstResult is
> the
> > > > > > > zero-based
> > > > > > > > > > > > index of the record you want to start with.
> SetMaxResults
> > > is
> > > > > the
> > > > > > > > > > > > number of records you want to return.
> >
> > > > > > > > > > > > if this is correct then why do tests:
> > > > > > > > > > > > Should_get_foos_21_through_30
> > > > > > > > > > > > Should_get_foos_31_through_40
> > > > > > > > > > > > fail?
> >
> > > > > > > > > > > > //Foo has 1 property Id which is readonly. The id is
> > > assigned
> > > > > via
> > > > > > > > > > > > ctor.
> >
> > > > > > > > > > > > namespace Paging.Spike.Core.Test
> > > > > > > > > > > > {
> > > > > > > > > > > >    [TestFixture]
> > > > > > > > > > > >    public class PagingWithNhibernateSpec
> > > > > > > > > > > >    {
> > > > > > > > > > > >        private ISessionFactory factory;
> > > > > > > > > > > >        private Configuration cfg;
> > > > > > > > > > > >        private ISession session;
> > > > > > > > > > > >        private const int PAGE_SIZE = 10;
> >
> > > > > > > > > > > >        [TestFixtureSetUp]
> > > > > > > > > > > >        public void TestFixtureSetup()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            cfg = new Configuration().Configure();
> > > > > > > > > > > >            factory = cfg.BuildSessionFactory();
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [TestFixtureTearDown]
> > > > > > > > > > > >        public void TestFixtureTeardown()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            factory.Dispose();
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [SetUp]
> > > > > > > > > > > >        public void SetUp()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            session = factory.OpenSession();
> > > > > > > > > > > >            new SchemaExport(cfg).Execute(false, true,
> > > false,
> > > > > > > true,
> > > > > > > > > > > > session.Connection, null);
> > > > > > > > > > > >            using(ITransaction transaction =
> > > > > > > > > > > > session.BeginTransaction())
> > > > > > > > > > > >            {
> > > > > > > > > > > >                for (int i = 1; i <= 100; i++)
> > > > > > > > > > > >                    session.Save(new Foo(i));
> > > > > > > > > > > >                transaction.Commit();
> > > > > > > > > > > >            }
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [TearDown]
> > > > > > > > > > > >        public void TearDown()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            session.Dispose();
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [Test]
> > > > > > > > > > > >        public void Should_get_foos_01_through_10()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            ValidateIdsStartingWithId(1,
> > > > > > > > > > > > GetResultsStartingAtIndex(0));
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [Test]
> > > > > > > > > > > >        public void Should_get_foos_11_through_20()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            ValidateIdsStartingWithId(11,
> > > > > > > > > > > > GetResultsStartingAtIndex(10));
> > > > > > > > > > > >        }
> >
> > > > > > > > > > > >        [Test]
> > > > > > > > > > > >        public void Should_get_foos_21_through_30()
> > > > > > > > > > > >        {
> > > > > > > > > > > >            ValidateIdsStartingWithId(21,
> >
> > ...
> >
> > read more »
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to