mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
41b92914f8
Initially, `TOP` was introduced to support `limit` for MSSQL database. Unlike PostgreSQL/MySQL/SQLite, MSSQL does not have native `LIMIT`/`OFFSET` support. The commit adding `TOP` is1a246f7161
. However, it figured out that `TOP` implementation was weak and it's not sufficient to also support `OFFSET`, then `TOP` was substituted with `ROW_NUMBER()` subquery inbe48ed3071
. This is a well known trick in MSSQL - https://stackoverflow.com/questions/2135418/equivalent-of-limit-and-offset-for-sql-server. So now we don't need this `visit_Arel_Nodes_Top` at all. It does nothing useful but also adds an extra space after `SELECT` when `LIMIT` is being used for **any** database.
44 lines
698 B
Ruby
44 lines
698 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
|
|
Ordering
|
|
RollUp
|
|
}.each do |name|
|
|
const_set(name, Class.new(Unary))
|
|
end
|
|
end
|
|
end
|