Commit graph

13 commits

Author SHA1 Message Date
Jasper Maes
db80db793f Replace deprecated uniq on a Relation with distinct 2018-10-26 18:19:28 +02:00
Yorick Peterse
8a72f5c427
Added FromUnion to easily select from a UNION
This commit adds the module `FromUnion`, which provides the class method
`from_union`. This simplifies the process of selecting data from the
result of a UNION, and reduces the likelihood of making mistakes. As a
result, instead of this:

    union = Gitlab::SQL::Union.new([foo, bar])

    Foo.from("(#{union.to_sql}) #{Foo.table_name}")

We can now write this instead:

    Foo.from_union([foo, bar])

This commit also includes some changes to make this new setup work
properly. For example, a bug in Rails 4
(https://github.com/rails/rails/issues/24193) would break the use of
`from("sub-query-here").includes(:relation)` in certain cases. There was
also a CI query which appeared to repeat a lot of conditions from an
outer query on an inner query, which isn't necessary.

Finally, we include a RuboCop cop to ensure developers use this new
module, instead of using Gitlab::SQL::Union directly.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/51307
2018-09-17 12:39:43 +02:00
Yorick Peterse
2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
gfyoung
265478ad74 Enable frozen string in apps/services/**/*.rb
For directories application_settings --> labels.

Partially addresses #47424.
2018-07-16 12:36:41 -07:00
Jan Provaznik
470b3cb5a1 Fix label links update on project transfer 2018-04-19 08:17:12 +00:00
Brian Neel
9770c57fab Re-enable SqlInjection and CommandInjection 2017-08-08 10:50:54 -04:00
Grzegorz Bizon
0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Douglas Barbosa Alexandre
1d8b74fee3 Avoid touch label links that does not belongs to project when moving it 2016-10-19 14:58:28 -02:00
Douglas Barbosa Alexandre
4f6d1c1d70 Rename Labels::CreateService to Labels::FindOrCreateService 2016-10-19 14:58:28 -02:00
Douglas Barbosa Alexandre
d009d38ed6 User Labes::CreateService to create labels 2016-10-19 14:58:27 -02:00
Douglas Barbosa Alexandre
49ec98d1b2 Recreates the label priorities when moving project to another group 2016-10-19 14:58:27 -02:00
Douglas Barbosa Alexandre
fc59d35720 Skip update query if label have the same id on Labels::TransferService 2016-10-19 14:58:26 -02:00
Douglas Barbosa Alexandre
8522ef44bf Recreates missing group labels when moving project to another group 2016-10-19 14:58:24 -02:00