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
163 164 165 166 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 163 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
158 159 160 161 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 158 def to_union_sql return unless union_values? apply_union_ordering(build_union_nodes!(false)).to_sql end |
#union(opts = :chain, *args) ⇒ Object
139 140 141 142 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 139 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
149 150 151 152 153 154 155 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 149 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
106 107 108 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 106 def unionize_storage @values.fetch(:unionize, {}) end |
#unionize_storage! ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'lib/active_record_extended/query_methods/unionize.rb', line 110 def unionize_storage! @values[:unionize] ||= { union_values: [], union_operations: [], union_ordering_values: [], unionized_name: nil, } end |