Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request mbleigh#461 from developer88/master
Browse files Browse the repository at this point in the history
Fix : Move 'Distinct' out of select string and use .uniq instead
  • Loading branch information
seuros committed Jan 29, 2014
2 parents 18c8b32 + a23ee92 commit 1e09618
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch.
* [@bzbnhang #440 Did not respect strict_case_match](https://github.com/mbleigh/acts-as-taggable-on/pull/440)
* [@znz #456 Fix breaking encoding of tag](https://github.com/mbleigh/acts-as-taggable-on/pull/456)
* [@rgould #417 Let '.count' work when tagged_with is accompanied by a group clause](https://github.com/mbleigh/acts-as-taggable-on/pull/417)
* [@developer88 #461 Move 'Distinct' out of select string and use .uniq instead](https://github.com/mbleigh/acts-as-taggable-on/pull/461)
* Misc
* [@billychan #463 Thread safe support](https://github.com/mbleigh/acts-as-taggable-on/pull/463)
* [@billychan #386 Add parse:true instructions to README](https://github.com/mbleigh/acts-as-taggable-on/pull/386)
Expand Down
6 changes: 4 additions & 2 deletions lib/acts_as_taggable_on/acts_as_taggable_on/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def tagged_with(tags, options = {})

# don't need to sanitize sql, map all ids and join with OR logic
conditions << tags.map { |t| "#{taggings_alias}.tag_id = #{quote_value(t.id, nil)}" }.join(" OR ")
select_clause = "DISTINCT #{table_name}.*" unless context and tag_types.one?
select_clause = " #{table_name}.*" unless context and tag_types.one?

if owned_by
tagging_join << " AND " +
Expand Down Expand Up @@ -200,13 +200,15 @@ def tagged_with(tags, options = {})

order_by << options[:order] if options[:order].present?

select(select_clause).
request = select(select_clause).
joins(joins.join(" ")).
where(conditions.join(" AND ")).
group(group).
having(having).
order(order_by.join(", ")).
readonly(false)

((context and tag_types.one?) && options.delete(:any)) ? request : request.uniq
end

def is_taggable?
Expand Down

0 comments on commit 1e09618

Please sign in to comment.