BigW Consortium Gitlab
Compared to the merge_request_diff association: 1. It's simpler to query. The query uses a foreign key to the merge_request_diffs table, so no ordering is necessary. 2. It's faster for preloading. The merge_request_diff association has to load every diff for the MRs in the set, then discard all but the most recent for each. This association means that Rails can just query for N diffs from N MRs. 3. It's more complicated to update. This is a bidirectional foreign key, so we need to update two tables when adding a diff record. This also means we need to handle this as a special case when importing a GitLab project. There is some juggling with this association in the merge request model: * `MergeRequest#latest_merge_request_diff` is _always_ the latest diff. * `MergeRequest#merge_request_diff` reuses `MergeRequest#latest_merge_request_diff` unless: * Arguments are passed. These are typically to force-reload the association. * It doesn't exist. That means we might be trying to implicitly create a diff. This only seems to happen in specs. * The association is already loaded. This is important for the reasons explained in the comment, which I'll reiterate here: if we a) load a non-latest diff, then b) get its `merge_request`, then c) get that MR's `merge_request_diff`, we should get the diff we loaded in c), even though that's not the latest diff. Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases, but not quite all.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
access_requestable_spec.rb | Loading commit data... | |
avatarable_spec.rb | Loading commit data... | |
awardable_spec.rb | Loading commit data... | |
cache_markdown_field_spec.rb | Loading commit data... | |
case_sensitivity_spec.rb | Loading commit data... | |
discussion_on_diff_spec.rb | Loading commit data... | |
each_batch_spec.rb | Loading commit data... | |
editable_spec.rb | Loading commit data... | |
expirable_spec.rb | Loading commit data... | |
faster_cache_keys_spec.rb | Loading commit data... | |
feature_gate_spec.rb | Loading commit data... | |
group_descendant_spec.rb | Loading commit data... | |
has_status_spec.rb | Loading commit data... | |
has_variable_spec.rb | Loading commit data... | |
ignorable_column_spec.rb | Loading commit data... | |
issuable_spec.rb | Loading commit data... | |
loaded_in_group_list_spec.rb | Loading commit data... | |
manual_inverse_association_spec.rb | Loading commit data... | |
mentionable_spec.rb | Loading commit data... | |
milestoneish_spec.rb | Loading commit data... | |
noteable_spec.rb | Loading commit data... | |
participable_spec.rb | Loading commit data... | |
presentable_spec.rb | Loading commit data... | |
project_features_compatibility_spec.rb | Loading commit data... | |
reactive_caching_spec.rb | Loading commit data... | |
relative_positioning_spec.rb | Loading commit data... | |
resolvable_discussion_spec.rb | Loading commit data... | |
resolvable_note_spec.rb | Loading commit data... | |
routable_spec.rb | Loading commit data... | |
sha_attribute_spec.rb | Loading commit data... | |
spammable_spec.rb | Loading commit data... | |
strip_attribute_spec.rb | Loading commit data... | |
subscribable_spec.rb | Loading commit data... | |
token_authenticatable_spec.rb | Loading commit data... | |
uniquify_spec.rb | Loading commit data... |