Replies: 1 comment 2 replies
-
The behavior is currently expected. Without an order, the default limit/offset paged_each strategy could result in the same row being yielded multiple times and missing rows, even when rows are not deleted/inserted. That issue isn't present on PostgreSQL, because it uses cursors for paged_each. I think it's reasonable to remove the implicit order on PostgreSQL. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I use method
SomeModel.dataset.paged_each
Sequel addsORDER BY
clause if dataset is associated with a model with a primary key.I use this method to declare a cursor in postgres and in some cases I do not want ordering.
Let's say I have a table
items
and model for it:This code doesn't add ordering and works as expected by me:
resulting in a query:
This code implicitly adds ordering:
resulting in a query:
I'm not sure if you'd consider it a bug, but it was an unexpected behavior for me. I understand that ordering is needed for pagination strategies in
Sequel::Dataset#paged_each
. I'm just not sure that adding implicit ordering is Sequel's responsibility.For postgres model dataset
#paged_each
first dispatches toSequel::Model::DatasetMethods#paged_each where
ORDER BY
is added and only then it goes up the inheritance chain to postgres specific implementationSequel::Postgres::Dataset#paged_each
.Addition of ordering can be bypassed by wrapping model dataset in "bare" dataset:
resulting in a query:
Postgres optimizes away this wrapping so it's an acceptable solution for me.
Here is a complete example:
and its output:
Beta Was this translation helpful? Give feedback.
All reactions