lib/arjdbc/postgresql/adapter.rb
# PostgreSQL requires the ORDER BY columns in the select list for distinct
# queries, and requires that the ORDER BY include the distinct column.
# @override Since AR 4.0 (on 4.1 {#distinct} is gone and won't be called).
PostgreSQL requires the ORDER BY columns in the select list for distinct
queries, and requires that the ORDER BY include the distinct column.
PostgreSQL requires the ORDER BY columns in the select list for distinct queries and requires that the ORDER BY include the distinct column .
def columns_for_distinct(columns, orders)
      if orders.is_a?(String)
        orders = orders.split(','); orders.each(&:strip!)
      end
      order_columns = orders.reject(&:blank?).map! do |column|
        column = column.to_sql unless column.is_a?(String) 
        column.gsub(/\s+(ASC|DESC)\s*(NULLS\s+(FIRST|LAST)\s*)?/i, '') 
      end
      order_columns.reject!(&:blank?)
      i = -1; order_columns.map! { |c| "#{c} AS alias_#{i += 1}" }
      columns = [ columns ]; columns.flatten!
      columns.push( *order_columns ).join(', ')
    end
def columns_for_distinct ( columns , orders ) if orders . is_a? ( String ) orders = orders . split ( ',' ) ; orders . each ( & :strip! ) end order_columns = orders . reject ( & :blank? ) . map! do | column | column = column . to_sql unless column . is_a? ( String ) column . gsub ( / \s +(ASC|DESC) \s *(NULLS \s +(FIRST|LAST) \s *)? /i , '' ) end order_columns . reject! ( & :blank? ) i = - 1 ; order_columns . map! { | c | "#{c} AS alias_#{i += 1}" } columns = [ columns ] ; columns . flatten! columns . push ( * order_columns ) . join ( ', ' ) end
PostgreSQL requires the ORDER BY columns in the select list for distinct
queries, and requires that the ORDER BY include the distinct column.
PostgreSQL requires the ORDER BY columns in the select list for distinct queries and requires that the ORDER BY include the distinct column .
# handle AREL node # remove ASC/DESC
columns
orders
override
Since AR 4.0 (on 4.1 {#distinct} is gone and won't be called).
Since AR 4 . 0 ( on 4 . 1 { #distinct } is gone and won ' t be called ) .