Adjust nulls_last_order
What does this MR do?
Use a more Arel friendly form of Gitlab::Database.nulls_last_order
The new Keyset::Connection
class (coming soon to an MR near you) parses the order values on a relation. By using this form
[Arel.sql("#{field} IS NULL"), field => direction]
instead of
Arel.sql("#{field} #{direction} NULLS LAST")
it's able to parse the order values much easier.
For example, using Issue.order_relative_position_asc.order_values
, originally you got
[1] pry(main)> Issue.order_relative_position_asc.order_values
=> ["relative_position ASC NULLS LAST"]
and now you get
[19] pry(main)> Issue.order_relative_position_asc.order_values
=> ["relative_position IS NULL",
#<Arel::Nodes::Ascending:0x00007faf76d45620
@expr=
#<struct Arel::Attributes::Attribute
relation=
#<Arel::Table:0x00007faf83549180
@name="issues",
@table_alias=nil,
@type_caster=
#<ActiveRecord::TypeCaster::Map:0x00007faf835491d0
@types=
Issue(id: integer, title: string, author_id: integer, project_id: integer, created_at: datetime, updated_at: datetime, description: text, milestone_id: integer, state: string, iid: integer, updated_by_id: integer, weight: integer, confidential: boolean, due_date: date, moved_to_id: integer, lock_version: integer, title_html: text, description_html: text, time_estimate: integer, relative_position: integer, service_desk_reply_to: string, cached_markdown_version: integer, last_edited_at: datetime, last_edited_by_id: integer, discussion_locked: boolean, closed_at: datetime_with_timezone, closed_by_id: integer, state_id: integer, duplicated_to_id: integer)>>,
name="relative_position">>]
Related to: #29713 (closed)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation created/updated or follow-up review issue created
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team