summaryrefslogtreecommitdiff
path: root/app/models/namespaces/traversal/linear.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 06:09:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 06:09:33 +0000
commit93f77228e32908b64ce7b9a3eb69e48efff11a9c (patch)
treea3481d6243243340b33395e7d632a9faaa6c4d4e /app/models/namespaces/traversal/linear.rb
parentd306693dd6f64b249690b487b5d5dca55d7a27b1 (diff)
downloadgitlab-ce-93f77228e32908b64ce7b9a3eb69e48efff11a9c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/namespaces/traversal/linear.rb')
-rw-r--r--app/models/namespaces/traversal/linear.rb20
1 files changed, 1 insertions, 19 deletions
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb
index 294ef83b9b4..dd9ca8d9bea 100644
--- a/app/models/namespaces/traversal/linear.rb
+++ b/app/models/namespaces/traversal/linear.rb
@@ -86,25 +86,7 @@ module Namespaces
raise UnboundedSearch.new('Must bound search by a top') unless top
without_sti_condition
- .traversal_ids_contains(latest_traversal_ids(top))
- end
-
- # traversal_ids are a cached value.
- #
- # The traversal_ids value in a loaded object can become stale when compared
- # to the database value. For example, if you load a hierarchy and then move
- # a group, any previously loaded descendant objects will have out of date
- # traversal_ids.
- #
- # To solve this problem, we never depend on the object's traversal_ids
- # value. We always query the database first with a sub-select for the
- # latest traversal_ids.
- #
- # Note that ActiveRecord will cache query results. You can avoid this by
- # using `Model.uncached { ... }`
- def latest_traversal_ids(namespace = self)
- without_sti_condition.where('id = (?)', namespace)
- .select('traversal_ids as latest_traversal_ids')
+ .traversal_ids_contains("{#{top.id}}")
end
end
end