Support empty GIDs
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
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. This is not a user facing change. -
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
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.