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
awardable_spec.rb
batch_destroy_dependent_associations_spec.rb
blocks_json_serialization_spec.rb
cache_markdown_field_spec.rb
cacheable_attributes_spec.rb
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
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
ignorable_column_spec.rb
issuable_spec.rb
loaded_in_group_list_spec.rb
manual_inverse_association_spec.rb
mentionable_spec.rb
milestoneish_spec.rb
noteable_spec.rb
optionally_search_spec.rb
participable_spec.rb
presentable_spec.rb
project_features_compatibility_spec.rb
prometheus_adapter_spec.rb
protected_ref_access_spec.rb
reactive_caching_spec.rb
redis_cacheable_spec.rb
relative_positioning_spec.rb
resolvable_discussion_spec.rb
resolvable_note_spec.rb
routable_spec.rb
sha_attribute_spec.rb
sortable_spec.rb
spammable_spec.rb
strip_attribute_spec.rb
subscribable_spec.rb
token_authenticatable_spec.rb
triggerable_hooks_spec.rb
uniquify_spec.rb