mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Mixed case tagging (#6454)
- By default, behaviour is not changed: tags are made lowercase upon creation and edit. - If force_lowercase_tags is disabled, then mixed case tags are allowed. - Tags must remain case-insensitively unique. This is enforced by ActiveRecord and Postgres. - A migration is added to provide a `UNIQUE` index on `lower(name)`. Migration includes a safety to correct any current tags that do not meet the criteria. - A `where_name` scope is added to `models/tag.rb`, to allow easy case-insensitive lookups. This is used instead of `Tag.where(name: "blah")`. - URLs remain lowercase. Mixed case URLs are functional, but have the lowercase equivalent as the canonical.
This commit is contained in:
@@ -634,11 +634,12 @@ class TopicQuery
|
||||
result = result.preload(:tags)
|
||||
|
||||
if @options[:tags] && @options[:tags].size > 0
|
||||
@options[:tags].each { |t| t.downcase! if t.is_a? String }
|
||||
|
||||
if @options[:match_all_tags]
|
||||
# ALL of the given tags:
|
||||
tags_count = @options[:tags].length
|
||||
@options[:tags] = Tag.where(name: @options[:tags]).pluck(:id) unless @options[:tags][0].is_a?(Integer)
|
||||
@options[:tags] = Tag.where_name(@options[:tags]).pluck(:id) unless @options[:tags][0].is_a?(Integer)
|
||||
|
||||
if tags_count == @options[:tags].length
|
||||
@options[:tags].each_with_index do |tag, index|
|
||||
@@ -654,7 +655,7 @@ class TopicQuery
|
||||
if @options[:tags][0].is_a?(Integer)
|
||||
result = result.where("tags.id in (?)", @options[:tags])
|
||||
else
|
||||
result = result.where("tags.name in (?)", @options[:tags])
|
||||
result = result.where("lower(tags.name) in (?)", @options[:tags])
|
||||
end
|
||||
end
|
||||
elsif @options[:no_tags]
|
||||
|
Reference in New Issue
Block a user