lib/active_record/connection_adapters/fdbsql/schema_statements.rb
# Returns a SELECT DISTINCT clause for a given set of columns
# and a given ORDER BY clause.
#
# Deprecated in 4.0 in favor of new columns_for_distinct API
Returns a SELECT DISTINCT clause for a given set of columns
and a given ORDER BY clause.


Returns a SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause .
def distinct(columns, orders)
            return super if orders.empty?
            order_columns = orders.collect { |s| s.gsub(/\s+(ASC|DESC)\s*(NULLS\s+(FIRST|LAST)\s*)?/i, '') }
            order_columns.delete_if { |c| c.blank? }
            order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| "#{s} AS alias_#{i}" }
            "DISTINCT #{columns}, #{order_columns * ', '}"
          end
def distinct ( columns , orders ) return super if orders . empty? order_columns = orders . collect { | s | s . gsub ( / \s +(ASC|DESC) \s *(NULLS \s +(FIRST|LAST) \s *)? /i , '' ) } order_columns . delete_if { | c | c . blank? } order_columns = order_columns . zip ( ( 0 ... order_columns . size ) . to_a ) . map { | s , i | "#{s} AS alias_#{i}" } "DISTINCT #{columns}, #{order_columns * ', '}" end
Returns a SELECT DISTINCT clause for a given set of columns
and a given ORDER BY clause.
Returns a SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause .
# Construct a clean list of column names from the ORDER BY clause, removing # any ASC/DESC modifiers
columns
orders