Module: ActiveRecordExtended::QueryMethods::Unionize
- Defined in:
- lib/active_record_extended/query_methods/unionize.rb
Defined Under Namespace
Classes: UnionChain
Constant Summary collapse
- UNION_RELATION_METHODS =
[:order_union, :reorder_union, :union_as].freeze
- UNIONIZE_METHODS =
[:union, :union_all, :union_except, :union_intersect].freeze
Instance Method Summary collapse
- #to_nice_union_sql(color = true) ⇒ Object
-
#to_union_sql ⇒ Object
Will construct Just the union SQL statement that was been built thus far.
- #union(opts = :chain, *args) ⇒ Object
- #union!(opts = :chain, *args, chain_method: :union) ⇒ Object
- #unionize_storage ⇒ Object
- #unionize_storage! ⇒ Object
Instance Method Details
#to_nice_union_sql(color = true) ⇒ Object
132 133 134 135 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 132 def to_nice_union_sql(color = true) return to_union_sql unless defined?(::Niceql) ::Niceql::Prettifier.prettify_sql(to_union_sql, color) end |
#to_union_sql ⇒ Object
Will construct Just the union SQL statement that was been built thus far
127 128 129 130 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 127 def to_union_sql return unless union_values? apply_union_ordering(build_union_nodes!(false)).to_sql end |
#union(opts = :chain, *args) ⇒ Object
108 109 110 111 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 108 def union(opts = :chain, *args) return UnionChain.new(spawn) if opts == :chain opts.nil? ? self : spawn.union!(opts, *args, chain_method: __callee__) end |
#union!(opts = :chain, *args, chain_method: :union) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 118 def union!(opts = :chain, *args, chain_method: :union) union_chain = UnionChain.new(self) chain_method ||= :union return union_chain if opts == :chain union_chain.public_send(chain_method, *([opts] + args)) end |
#unionize_storage ⇒ Object
75 76 77 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 75 def unionize_storage @values.fetch(:unionize, {}) end |
#unionize_storage! ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 79 def unionize_storage! @values[:unionize] ||= { union_values: [], union_operations: [], union_ordering_values: [], unionized_name: nil, } end |