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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
530cf2a2
Commit
530cf2a2
authored
Sep 07, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't break when building unions on empty collections
parent
438a0773
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
lib/gitlab/sql/union.rb
lib/gitlab/sql/union.rb
+5
-1
spec/lib/gitlab/sql/union_spec.rb
spec/lib/gitlab/sql/union_spec.rb
+7
-0
No files found.
lib/gitlab/sql/union.rb
View file @
530cf2a2
...
...
@@ -26,7 +26,11 @@ module Gitlab
@relations
.
map
{
|
rel
|
rel
.
reorder
(
nil
).
to_sql
}.
reject
(
&
:blank?
)
end
if
fragments
.
any?
fragments
.
join
(
"
\n
#{
union_keyword
}
\n
"
)
else
'NULL'
end
end
def
union_keyword
...
...
spec/lib/gitlab/sql/union_spec.rb
View file @
530cf2a2
...
...
@@ -29,5 +29,12 @@ describe Gitlab::SQL::Union do
expect
(
union
.
to_sql
).
to
include
(
'UNION ALL'
)
end
it
'returns `NULL` if all relations are empty'
do
empty_relation
=
User
.
none
union
=
described_class
.
new
([
empty_relation
,
empty_relation
])
expect
(
union
.
to_sql
).
to
eq
(
'NULL'
)
end
end
end
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