Improve tag search query (#16104)
This commit is contained in:
parent
daccc07dc1
commit
7f0c49c58a
4 changed files with 35 additions and 10 deletions
|
@ -96,6 +96,20 @@ RSpec.describe Tag, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.matches_name' do
|
||||
it 'returns tags for multibyte case-insensitive names' do
|
||||
upcase_string = 'abcABCabcABCやゆよ'
|
||||
downcase_string = 'abcabcabcabcやゆよ';
|
||||
|
||||
tag = Fabricate(:tag, name: downcase_string)
|
||||
expect(Tag.matches_name(upcase_string)).to eq [tag]
|
||||
end
|
||||
|
||||
it 'uses the LIKE operator' do
|
||||
expect(Tag.matches_name('100%abc').to_sql).to eq %q[SELECT "tags".* FROM "tags" WHERE LOWER("tags"."name") LIKE LOWER('100\\%abc%')]
|
||||
end
|
||||
end
|
||||
|
||||
describe '.matching_name' do
|
||||
it 'returns tags for multibyte case-insensitive names' do
|
||||
upcase_string = 'abcABCabcABCやゆよ'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue