Skip to content

Commit

Permalink
Initial commit to support distinct_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
yahonda committed Nov 29, 2012
1 parent 458e177 commit 9fed43a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
Expand Up @@ -1234,7 +1234,7 @@ def has_primary_key?(table_name, owner=nil, desc_table_name=nil, db_link=nil) #:
# making every row the same.
#
# distinct("posts.id", "posts.created_at desc")
def distinct(columns, order_by) #:nodoc:
def distinct_columns(columns, order_by) #:nodoc:
# construct a valid DISTINCT clause, ie. one that includes the ORDER BY columns, using
# FIRST_VALUE such that the inclusion of these columns doesn't invalidate the DISTINCT
order_columns = order_by.map { |c|
Expand All @@ -1244,7 +1244,14 @@ def distinct(columns, order_by) #:nodoc:
}.reject(&:blank?).map.with_index { |c,i|
"FIRST_VALUE(#{c}) OVER (PARTITION BY #{columns} ORDER BY #{c}) AS alias_#{i}__"
}
[super].concat(order_columns).join(', ')
# Return as `String`
puts super.concat(order_columns).join(', ').class
puts super.concat(order_columns).join(', ')
super.concat(order_columns).join(', ')
# Return as `Array`
#puts super.concat(order_columns).class
#puts super.concat(order_columns)
#super.concat(order_columns)
end

def temporary_table?(table_name) #:nodoc:
Expand Down

0 comments on commit 9fed43a

Please sign in to comment.