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
7e7c7029
Commit
7e7c7029
authored
Jul 21, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ambiguous query error on milestone_id
parent
ce8b4cbc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
app/models/concerns/milestoneable.rb
app/models/concerns/milestoneable.rb
+1
-1
changelogs/unreleased/fix-ambiguous-query-error.yml
changelogs/unreleased/fix-ambiguous-query-error.yml
+6
-0
spec/models/concerns/milestoneable_spec.rb
spec/models/concerns/milestoneable_spec.rb
+17
-1
No files found.
app/models/concerns/milestoneable.rb
View file @
7e7c7029
...
...
@@ -15,7 +15,7 @@ module Milestoneable
validate
:milestone_is_valid
scope
:of_milestones
,
->
(
ids
)
{
where
(
milestone_id:
ids
)
}
scope
:any_milestone
,
->
{
where
(
'milestone_id IS NOT NULL'
)
}
scope
:any_milestone
,
->
{
where
.
not
(
milestone_id:
nil
)
}
scope
:with_milestone
,
->
(
title
)
{
left_joins_milestones
.
where
(
milestones:
{
title:
title
})
}
scope
:without_particular_milestone
,
->
(
title
)
{
left_outer_joins
(
:milestone
).
where
(
"milestones.title != ? OR milestone_id IS NULL"
,
title
)
}
scope
:any_release
,
->
{
joins_milestone_releases
}
...
...
changelogs/unreleased/fix-ambiguous-query-error.yml
0 → 100644
View file @
7e7c7029
---
title
:
Fix ambiguous query error when filtering for Any milestone in Value Stream
Analytics
merge_request
:
37451
author
:
type
:
fixed
spec/models/concerns/milestoneable_spec.rb
View file @
7e7c7029
...
...
@@ -103,7 +103,7 @@ RSpec.describe Milestoneable do
end
describe
'release scopes'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:release_1
)
{
create
(
:release
,
tag:
'v1.0'
,
project:
project
)
}
let_it_be
(
:release_2
)
{
create
(
:release
,
tag:
'v2.0'
,
project:
project
)
}
...
...
@@ -126,6 +126,22 @@ RSpec.describe Milestoneable do
let_it_be
(
:items
)
{
Issue
.
all
}
describe
'#any_milestone'
do
context
'when milestone filter is present and related closing issues are joined'
do
let_it_be
(
:merge_request_1
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature-1'
)
}
let_it_be
(
:merge_request_2
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'feature-2'
)
}
let_it_be
(
:mrc_issue_1
)
{
create
(
:merge_requests_closing_issues
,
issue:
issue_1
,
merge_request:
merge_request_1
)
}
let_it_be
(
:mrc_issue_2
)
{
create
(
:merge_requests_closing_issues
,
issue:
issue_2
,
merge_request:
merge_request_2
)
}
it
'returns merge request closing issues of any milestone'
do
relation
=
items
.
joins
(
merge_requests_closing_issues: :issue
).
any_milestone
expect
(
relation
).
to
contain_exactly
(
issue_1
,
issue_2
)
end
end
end
describe
'#without_release'
do
it
'returns the issues not tied to any milestone and the ones tied to milestone with no release'
do
expect
(
items
.
without_release
).
to
contain_exactly
(
issue_5
,
issue_6
)
...
...
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