lib/active_record_extended/query_methods/unionize.rb
# Apply's the allowed ORDER BY to the end of the final union statement
#
# Note: This will only apply at the very end of the union statements. Not nested ones.
#       (I guess you could double nest a union and apply it, but that would be dumb)
#
# Example:
#   User.union(User.select(:id).where(id: 8))
#       .union(User.select(:id).where(id: 50))
#       .union.order(id: :desc)
#  #=> [<#User id: 50>, <#User id: 8>]
#
#   ```sql
#   SELECT users.*
#   FROM(
#       (SELECT users.id FROM users WHERE id = 8)
#       UNION
#       (SELECT users.id FROM users WHERE id = 50)
#       ORDER BY id DESC
#    ) users;
#   ```
#
Apply's the allowed ORDER BY to the end of the final union statement
Note: This will only apply at the very end of the union statements. Not nested ones.
(I guess you could double nest a union and apply it, but that would be dumb)



```sql
SELECT users.
Apply ' s the allowed ORDER BY to the end of the final union statement Note : This will only apply at the very end of the union statements . Not nested ones . ( I guess you could double nest a union and apply it but that would be dumb ) ` ` ` sql SELECT users .
def apply_union_ordering(union_nodes)
        return union_nodes unless union_ordering_values?
        preprocess_order_args(union_ordering_values)
        union_ordering_values.uniq!
        Arel::Nodes::InfixOperation.new("ORDER BY", union_nodes, union_ordering_values)
      end
def apply_union_ordering ( union_nodes ) return union_nodes unless union_ordering_values? preprocess_order_args ( union_ordering_values ) union_ordering_values . uniq! Arel :: Nodes :: InfixOperation . new ( "ORDER BY" , union_nodes , union_ordering_values ) end
Apply's the allowed ORDER BY to the end of the final union statement
Note: This will only apply at the very end of the union statements.
Apply ' s the allowed ORDER BY to the end of the final union statement Note : This will only apply at the very end of the union statements .
# Sanitation check / resolver (ActiveRecord::Relation#preprocess_order_args)
union_nodes