Skip to content
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

[GRO-15761] Added new attribute on class SqlSort which would keep nul… #47

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

NileshN
Copy link
Contributor

@NileshN NileshN commented Sep 3, 2023

…ls last to sort order if configured in the object

…ls last to sort order if configured in the object
else
direction = "desc nulls last"
end
else
direction = "asc"
direction = @keep_nulls_last ? "asc nulls last" : "asc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NileshN How do you enable this variable? It is by default false.
If I want to support the asc nulls last then we need to send this parameter to the query_helper.update method from our application right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question @AjitKonde-Pattern. Here is the way to enable value to this attribute from the query-helper object:
@query_helper.update(........., sql_sort: QueryHelper::SqlSort.new( sort_string: params[:sort], keep_nulls_last: true ))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NileshN
Solution to this. In query_helper(lib/query_helper.rb) update method, you need to add below code:
@sql_sort.keep_nulls_last= keep_nulls_last if keep_nulls_last

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In application, you just need pass the value:
@query_helper.update(query: query, keep_nulls_last: true)

@NileshN NileshN merged commit 360f1f1 into master Sep 4, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants