Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions lib/acts-as-taggable-on/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def validates_name_uniqueness?

def self.named(name)
if ActsAsTaggableOn.strict_case_match
where(["name = #{binary}?", as_8bit_ascii(name)])
where(["name = #{binary}?", name.to_s])
else
where(['LOWER(name) = LOWER(?)', as_8bit_ascii(unicode_downcase(name))])
where(['LOWER(name) = LOWER(?)', name.to_s.downcase])
end
end

Expand Down Expand Up @@ -118,27 +118,19 @@ def comparable_name(str)
if ActsAsTaggableOn.strict_case_match
str
else
unicode_downcase(str.to_s)
str.to_s.downcase
end
end

def binary
ActsAsTaggableOn::Utils.using_mysql? ? 'BINARY ' : nil
end

def as_8bit_ascii(string)
string.to_s.mb_chars
end

def unicode_downcase(string)
as_8bit_ascii(string).downcase
end

def sanitize_sql_for_named_any(tag)
if ActsAsTaggableOn.strict_case_match
sanitize_sql(["name = #{binary}?", as_8bit_ascii(tag)])
sanitize_sql(["name = #{binary}?", tag.to_s])
else
sanitize_sql(['LOWER(name) = LOWER(?)', as_8bit_ascii(unicode_downcase(tag))])
sanitize_sql(['LOWER(name) = LOWER(?)', tag.to_s.downcase])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/acts-as-taggable-on/tag_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def clean!
reject!(&:blank?)
map!(&:to_s)
map!(&:strip)
map! { |tag| tag.mb_chars.downcase.to_s } if ActsAsTaggableOn.force_lowercase
map! { |tag| tag.to_s.downcase } if ActsAsTaggableOn.force_lowercase
map!(&:parameterize) if ActsAsTaggableOn.force_parameterize

ActsAsTaggableOn.strict_case_match ? uniq! : uniq!(&:downcase)
Expand Down