gitlab-org--gitlab-foss/spec/models/concerns
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
..
access_requestable_spec.rb
avatarable_spec.rb Disable project avatar validation if avatar has not changed 2018-09-04 12:20:58 -07:00
awardable_spec.rb Allows author to vote on their own issue 2018-08-24 10:13:41 +00:00
batch_destroy_dependent_associations_spec.rb Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
blocks_json_serialization_spec.rb
cache_markdown_field_spec.rb Use proper markdown rendering for previews 2018-07-06 18:49:33 +00:00
cacheable_attributes_spec.rb Stop relying on migrations in the CacheableAttributes cache key and cache attributes for 1 minute instead 2018-07-05 12:34:15 +02:00
case_sensitivity_spec.rb Port changes for CODEOWNERS to CE 2018-09-06 09:07:19 +02:00
chronic_duration_attribute_spec.rb
deployment_platform_spec.rb
discussion_on_diff_spec.rb Persist truncated note diffs on a new table 2018-05-24 15:34:43 -03:00
each_batch_spec.rb
editable_spec.rb
expirable_spec.rb
faster_cache_keys_spec.rb
feature_gate_spec.rb
from_union_spec.rb Added FromUnion to easily select from a UNION 2018-09-17 12:39:43 +02:00
group_descendant_spec.rb
has_status_spec.rb
has_variable_spec.rb Upgrade to Ruby 2.4.4 2018-05-29 15:19:33 -07:00
ignorable_column_spec.rb
issuable_spec.rb Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
loaded_in_group_list_spec.rb
manual_inverse_association_spec.rb
mentionable_spec.rb Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
milestoneish_spec.rb
noteable_spec.rb
optionally_search_spec.rb Refactor AutocompleteController 2018-08-20 13:53:00 +02:00
participable_spec.rb
presentable_spec.rb
project_features_compatibility_spec.rb
prometheus_adapter_spec.rb
protected_ref_access_spec.rb Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
reactive_caching_spec.rb Squashed commit of the following: 2018-08-07 23:03:48 +09:00
redis_cacheable_spec.rb
relative_positioning_spec.rb
resolvable_discussion_spec.rb Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
resolvable_note_spec.rb Check if note's noteable is not nil when checking resolvability 2018-05-23 16:58:40 +02:00
routable_spec.rb Remove code for dynamically generating routes 2018-07-25 16:41:29 +02:00
sha_attribute_spec.rb
sortable_spec.rb Fix sorting by name on explore projects page 2018-06-25 18:31:30 -03:00
spammable_spec.rb
strip_attribute_spec.rb
subscribable_spec.rb
token_authenticatable_spec.rb Export assigned issues in iCalendar feed 2018-05-31 14:01:04 +00:00
triggerable_hooks_spec.rb Refactor: move active hook filter to TriggerableHooks 2018-09-05 21:58:52 +10:00
uniquify_spec.rb