-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order with Nulls Last #1590
Comments
That sounds fine to me, but what about ascending order? It seems like we should definitely have tests for this... I wonder how you test based on the DB connection. Also @thegreyjoy, I should note that it's perfectly acceptable to open a pull request in this stage, to get feedback. Also, Github Issues is really meant for bug reports :P If you want to be fancy, you can create a pull request out of this existing Issue without creating a separate PR number. |
Thanks for the link, good to know you can do that. I'm closing this and discussing it over in the PR. |
Was this ever pulled in? I am having the same issue and the latest doesn't seem to fix it. |
No, the solution I proposed wasn't ideal. You can get around the issue by overriding the method active_admin_collection in the controller that needs it. You could also probably put the override into an initializer. def active_admin_collection
params[:order] ||= active_admin_config.sort_order
if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
column = $1
order = $2
table = active_admin_config.resource_table_name
table_column = (column =~ /\./) ? column :
"#{table}.#{active_admin_config.resource_quoted_column_name(column)}"
super.reorder("#{table_column} #{order} nulls last")
else
super
end
end |
I just ran across this issue today. @corybuecker's patch is out of date, but I made a new one. I'd be interested if this was merged into the codebase! |
Is there a reason why anyone would desire the default behavior that Postgres provides? Should we make the behavior configurable in Active Admin?
|
ransack issue activerecord-hackery/ransack#443 |
I've been using a forked version with that 3 line patch for over a year and it's been working fine and dandy. |
test and feedback are appriciated |
I posted a note in the AA Google Group to determine if this problem is actually a lack of understanding on my part. There was no answer there, and before I submit a pull request I want to make sure that I'm not missing something obvious.
When using PostgreSQL and AA, there is an issue with sorting a column that contains null values. PostgreSQL places null values before non-null values when descending order is specified. This is opposite of MySQL's behavior.
I've made the follow change to the sorting module, but I want to get some feedback before I submit it. Please let me know if there is a better way to approach this issue.
The text was updated successfully, but these errors were encountered: