diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-08 18:08:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-08 18:08:41 +0300 |
commit | dc47d7f5c0f1a402463e9c1adaffecf3f465bc7f (patch) | |
tree | 5fbe362a06ef1841c73d6b377dbccc5dfc7fcece /lib/gitlab/ci/pipeline_object_hierarchy.rb | |
parent | a0158b1a9c21f648fdbf79765bbc1e19e776b5d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/pipeline_object_hierarchy.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline_object_hierarchy.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline_object_hierarchy.rb b/lib/gitlab/ci/pipeline_object_hierarchy.rb new file mode 100644 index 00000000000..55e6cfb1b73 --- /dev/null +++ b/lib/gitlab/ci/pipeline_object_hierarchy.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Gitlab + module Ci + class PipelineObjectHierarchy < ::Gitlab::ObjectHierarchy + private + + def middle_table + ::Ci::Sources::Pipeline.arel_table + end + + def from_tables(cte) + [objects_table, cte.table, middle_table] + end + + def parent_id_column(_cte) + middle_table[:source_pipeline_id] + end + + def ancestor_conditions(cte) + middle_table[:source_pipeline_id].eq(objects_table[:id]).and( + middle_table[:pipeline_id].eq(cte.table[:id]) + ) + end + + def descendant_conditions(cte) + middle_table[:pipeline_id].eq(objects_table[:id]).and( + middle_table[:source_pipeline_id].eq(cte.table[:id]) + ) + end + end + end +end |