Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2f2ceb09
Commit
2f2ceb09
authored
Jan 19, 2022
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce linear descendants feature flag
parent
fb0c3d82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
2 deletions
+75
-2
app/models/namespaces/traversal/linear_scopes.rb
app/models/namespaces/traversal/linear_scopes.rb
+7
-2
config/feature_flags/development/use_traversal_ids_for_descendants_scopes.yml
.../development/use_traversal_ids_for_descendants_scopes.yml
+8
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+60
-0
No files found.
app/models/namespaces/traversal/linear_scopes.rb
View file @
2f2ceb09
...
@@ -53,7 +53,7 @@ module Namespaces
...
@@ -53,7 +53,7 @@ module Namespaces
end
end
def
self_and_descendants
(
include_self:
true
)
def
self_and_descendants
(
include_self:
true
)
return
super
unless
use_traversal_ids?
return
super
unless
use_traversal_ids
_for_descendants_scopes
?
if
Feature
.
enabled?
(
:traversal_ids_btree
,
default_enabled: :yaml
)
if
Feature
.
enabled?
(
:traversal_ids_btree
,
default_enabled: :yaml
)
self_and_descendants_with_comparison_operators
(
include_self:
include_self
)
self_and_descendants_with_comparison_operators
(
include_self:
include_self
)
...
@@ -65,7 +65,7 @@ module Namespaces
...
@@ -65,7 +65,7 @@ module Namespaces
end
end
def
self_and_descendant_ids
(
include_self:
true
)
def
self_and_descendant_ids
(
include_self:
true
)
return
super
unless
use_traversal_ids?
return
super
unless
use_traversal_ids
_for_descendants_scopes
?
if
Feature
.
enabled?
(
:traversal_ids_btree
,
default_enabled: :yaml
)
if
Feature
.
enabled?
(
:traversal_ids_btree
,
default_enabled: :yaml
)
self_and_descendants_with_comparison_operators
(
include_self:
include_self
).
as_ids
self_and_descendants_with_comparison_operators
(
include_self:
include_self
).
as_ids
...
@@ -109,6 +109,11 @@ module Namespaces
...
@@ -109,6 +109,11 @@ module Namespaces
use_traversal_ids?
use_traversal_ids?
end
end
def
use_traversal_ids_for_descendants_scopes?
Feature
.
enabled?
(
:use_traversal_ids_for_descendants_scopes
,
default_enabled: :yaml
)
&&
use_traversal_ids?
end
def
self_and_descendants_with_comparison_operators
(
include_self:
true
)
def
self_and_descendants_with_comparison_operators
(
include_self:
true
)
base
=
all
.
select
(
base
=
all
.
select
(
:traversal_ids
,
:traversal_ids
,
...
...
config/feature_flags/development/use_traversal_ids_for_descendants_scopes.yml
0 → 100644
View file @
2f2ceb09
---
name
:
use_traversal_ids_for_descendants_scopes
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78542
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/350637
milestone
:
'
14.8'
type
:
development
group
:
group::authentication and authorization
default_enabled
:
true
spec/models/namespace_spec.rb
View file @
2f2ceb09
...
@@ -361,6 +361,66 @@ RSpec.describe Namespace do
...
@@ -361,6 +361,66 @@ RSpec.describe Namespace do
context
'linear'
do
context
'linear'
do
it_behaves_like
'namespace traversal scopes'
it_behaves_like
'namespace traversal scopes'
end
end
shared_examples
'makes recursive queries'
do
specify
do
expect
{
subject
}.
to
make_queries_matching
(
/WITH RECURSIVE/
)
end
end
shared_examples
'does not make recursive queries'
do
specify
do
expect
{
subject
}.
not_to
make_queries_matching
(
/WITH RECURSIVE/
)
end
end
describe
'.self_and_descendants'
do
let_it_be
(
:namespace
)
{
create
(
:namespace
)
}
subject
{
described_class
.
where
(
id:
namespace
).
self_and_descendants
.
load
}
it_behaves_like
'does not make recursive queries'
context
'when feature flag :use_traversal_ids is disabled'
do
before
do
stub_feature_flags
(
use_traversal_ids:
false
)
end
it_behaves_like
'makes recursive queries'
end
context
'when feature flag :use_traversal_ids_for_descendants_scopes is disabled'
do
before
do
stub_feature_flags
(
use_traversal_ids_for_descendants_scopes:
false
)
end
it_behaves_like
'makes recursive queries'
end
end
describe
'.self_and_descendant_ids'
do
let_it_be
(
:namespace
)
{
create
(
:namespace
)
}
subject
{
described_class
.
where
(
id:
namespace
).
self_and_descendant_ids
.
load
}
it_behaves_like
'does not make recursive queries'
context
'when feature flag :use_traversal_ids is disabled'
do
before
do
stub_feature_flags
(
use_traversal_ids:
false
)
end
it_behaves_like
'makes recursive queries'
end
context
'when feature flag :use_traversal_ids_for_descendants_scopes is disabled'
do
before
do
stub_feature_flags
(
use_traversal_ids_for_descendants_scopes:
false
)
end
it_behaves_like
'makes recursive queries'
end
end
end
end
context
'traversal_ids on create'
do
context
'traversal_ids on create'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment