1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/nodes/unary.rb
Kevin Deisz 66b19b5dec
Allow #nulls_first and #nulls_last in PostgreSQL
When using PostgreSQL, it's useful to be able to specify NULLS FIRST and NULLS LAST on ordered columns. With this commit you can do that now, as in:

```ruby
User.arel_table[:first_name].desc.nulls_last
```
2019-12-31 15:59:59 -05:00

44 lines
704 B
Ruby

# frozen_string_literal: true
module Arel # :nodoc: all
module Nodes
class Unary < Arel::Nodes::NodeExpression
attr_accessor :expr
alias :value :expr
def initialize(expr)
super()
@expr = expr
end
def hash
@expr.hash
end
def eql?(other)
self.class == other.class &&
self.expr == other.expr
end
alias :== :eql?
end
%w{
Bin
Cube
DistinctOn
Group
GroupingElement
GroupingSet
Lateral
Limit
Lock
Not
Offset
On
OptimizerHints
RollUp
}.each do |name|
const_set(name, Class.new(Unary))
end
end
end