Skip to content

Support empty GIDs

Alex Kalderimis requested to merge nil-safe-object_from_id into master

What does this MR do?

This MR adds a new method to handle nil or empty GIDs. This avoids the need to use the pattern:

object = object_id ? Gitlab::Schema.object_from_id(object_id) : nil

Instead permitting:

object = Gitlab::Schema.object_from_id_when_present(object_id)

This avoids branching in methods, making them less complex and more intelligible. When nil GIDs represent the absence of objects, this method can more declaratively express this intent.

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

This does not change any existing methods, and is purely opt-in. It does not change the app behaviour in any way.

Merge request reports