Pagination on PostgreSQL

Posts   
 
    
garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 11-Jul-2010 15:55:47   

Quick question about pageSize and pageNumber

I've been trying to get pagination working (LLBL 3 with PostgreSQL 8.4) but I'm not sure if I'm reading the docs wrong or there's a bug.

Executing the following: adapter.FetchEntityCollection(_collection, _bucket, 0, _sorter, _path, 1, 10); executes: DESC LIMIT 0 OFFSET 10

I'd have expected that to execute LIMIT 10 OFFSET 0

Also, executing the following: adapter.FetchEntityCollection(_collection, _bucket, 0, _sorter, _path, 4, 10); executes: DESC LIMIT 30 OFFSET 10

Should this not be LIMIT 10 OFFSET 30?

I double checked the intellisense and its definitely pageNumber first, pageSize second.

So then I tried: adapter.FetchEntityCollection(_collection, _bucket, 0, _sorter, _path, 10, 4); and this executes: DESC LIMIT 36 OFFSET 4

Anyhow, you get the idea I'm sure, am I wrong or is LLBL?

Thanks! Garrett

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 11-Jul-2010 18:37:46   

Bug in DQE. v2.6: normalQuery.Command.CommandText = String.Format("SELECT {2} LIMIT {0} OFFSET {1}", pageSize, ((pageNumber - 1) * pageSize), normalQuery.Command.CommandText.Substring(6));

v3.0: normalQuery.Command.CommandText = string.Format("{0} LIMIT {1} OFFSET {2}", normalQuery.Command.CommandText, ((pageNumber - 1) * pageSize), pageSize);

Will attach a fix, just a sec. (lesson to learn: never ever mess up the order of {x} placeholders in a string and port it to a newer version: it's likely you'll mix up parameters... flushed )

(edit: attached)

Attachments
Filename File size Added on Approval
SD.LLBLGen.Pro.DQE.PostgreSql.NET20.dll 22,528 11-Jul-2010 18:39.14 Approved
Frans Bouma | Lead developer LLBLGen Pro
garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 12-Jul-2010 08:48:12   

Otis wrote:

Bug in DQE. v2.6: normalQuery.Command.CommandText = String.Format("SELECT {2} LIMIT {0} OFFSET {1}", pageSize, ((pageNumber - 1) * pageSize), normalQuery.Command.CommandText.Substring(6));

v3.0: normalQuery.Command.CommandText = string.Format("{0} LIMIT {1} OFFSET {2}", normalQuery.Command.CommandText, ((pageNumber - 1) * pageSize), pageSize);

Will attach a fix, just a sec. (lesson to learn: never ever mess up the order of {x} placeholders in a string and port it to a newer version: it's likely you'll mix up parameters... flushed )

(edit: attached)

No worries Frans

We've all done it a hundred times before, we'll all do it a hundred times again :-p

Thanks! Garrett

p.s Unlucky last night for the Oranje!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 12-Jul-2010 10:35:05   

garrett wrote:

Otis wrote:

Bug in DQE. v2.6: normalQuery.Command.CommandText = String.Format("SELECT {2} LIMIT {0} OFFSET {1}", pageSize, ((pageNumber - 1) * pageSize), normalQuery.Command.CommandText.Substring(6));

v3.0: normalQuery.Command.CommandText = string.Format("{0} LIMIT {1} OFFSET {2}", normalQuery.Command.CommandText, ((pageNumber - 1) * pageSize), pageSize);

Will attach a fix, just a sec. (lesson to learn: never ever mess up the order of {x} placeholders in a string and port it to a newer version: it's likely you'll mix up parameters... flushed )

(edit: attached)

No worries Frans

We've all done it a hundred times before, we'll all do it a hundred times again :-p

Thanks! Garrett

p.s Unlucky last night for the Oranje!

You can say that! cry ... oh well.. we'll live wink

Frans Bouma | Lead developer LLBLGen Pro