[Feature][ActiveRecord] Add NULLS LAST ordering to Arel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Feature][ActiveRecord] Add NULLS LAST ordering to Arel

harrymaclean
Hi team!

We're currently using Arel to dynamically construct complex SQL queries that power sorting and pagination in our API. One of the features we'd like to make use of is the NULLS LAST modifier in ORDER BY clauses. Arel has no support for this, but it's a small and straightforward patch (see https://github.com/hmac/rails/commit/7cab443ab1e67536d8d4e7a49c7126c815a96ad5).

Would anyone be against adding this feature?

Further info:

- the patch only adds support for PostgreSQL since I know it supports this feature - I'm happy to add it to other visitors if we can confirm their support.
- similarly, we can easily add NULLS FIRST support as well (we don't need it ourselves so it's not included here).

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature][ActiveRecord] Add NULLS LAST ordering to Arel

Andrew Kaspick
I just use a raw sql string for NULLS LAST.

On Wed, Aug 15, 2018 at 4:16 AM harrymaclean via Ruby on Rails: Core <[hidden email]> wrote:
Hi team!

We're currently using Arel to dynamically construct complex SQL queries that power sorting and pagination in our API. One of the features we'd like to make use of is the NULLS LAST modifier in ORDER BY clauses. Arel has no support for this, but it's a small and straightforward patch (see https://github.com/hmac/rails/commit/7cab443ab1e67536d8d4e7a49c7126c815a96ad5).

Would anyone be against adding this feature?

Further info:

- the patch only adds support for PostgreSQL since I know it supports this feature - I'm happy to add it to other visitors if we can confirm their support.
- similarly, we can easily add NULLS FIRST support as well (we don't need it ourselves so it's not included here).

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature][ActiveRecord] Add NULLS LAST ordering to Arel

harrymaclean
Hi Andrew,

So far we've managed to entirely avoid using SQL literals for this component, instead relying on (and trusting) Arel. If possible I'd like to keep that constraint, because it has a number of safety advantages (namely, discouraging the use of SQL literals). Arel nodes also arguably have better ergonomics, in that we can fold them together using #and and #or and be fairly confident that we'll get valid SQL out at the end.

On 15 August 2018 at 12:29, Andrew Kaspick <[hidden email]> wrote:
I just use a raw sql string for NULLS LAST.

On Wed, Aug 15, 2018 at 4:16 AM harrymaclean via Ruby on Rails: Core <[hidden email]> wrote:
Hi team!

We're currently using Arel to dynamically construct complex SQL queries that power sorting and pagination in our API. One of the features we'd like to make use of is the NULLS LAST modifier in ORDER BY clauses. Arel has no support for this, but it's a small and straightforward patch (see https://github.com/hmac/rails/commit/7cab443ab1e67536d8d4e7a49c7126c815a96ad5).

Would anyone be against adding this feature?

Further info:

- the patch only adds support for PostgreSQL since I know it supports this feature - I'm happy to add it to other visitors if we can confirm their support.
- similarly, we can easily add NULLS FIRST support as well (we don't need it ourselves so it's not included here).

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-core/VsoBNk4_JFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.