remove double quotes from search term

This commit is contained in:
Bilal Catic
2020-01-31 16:11:12 +01:00
parent 84a48b4acf
commit 87712860dd
2 changed files with 14 additions and 8 deletions

View File

@@ -21,15 +21,15 @@ class SqlGeneratorTester
end
it 'tests simple search term without column name and with quotes' do
@query = TextToSqlQuery.new('"ab"', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id')
@query = TextToSqlQuery.new('ab', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id')
expect(@query.where_clause).to eq ['players.device_id ILIKE ?', '%"ab"%']
expect(@query.where_clause).to eq ['players.device_id ILIKE ?', '%ab%']
end
it 'tests simple search term with column name and with quotes' do
@query = TextToSqlQuery.new('tag:"ab"', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id')
expect(@query.where_clause).to eq ['players.tag ILIKE ?', '%"ab"%']
expect(@query.where_clause).to eq ['players.tag ILIKE ?', '%ab%']
end
it 'tests search without operators' do
@@ -89,7 +89,13 @@ class SqlGeneratorTester
it 'tests search with special characters in search term' do
@query = TextToSqlQuery.new('title:"%a_\"', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id')
expect(@query.where_clause).to eq ['players.title ILIKE ?', '%"\%a\_\\"%']
expect(@query.where_clause).to eq ['players.title ILIKE ?', '%\%a\_\\%']
end
it 'tests search with field mappings' do
@query = TextToSqlQuery.new('tags:h1-r', [:'players.title', :'players.name', :'players.device_id'], :'players.device_id', { tags: "tags.name" })
expect(@query.where_clause).to eq ['tags.name ILIKE ?', '%h1-r%']
end
end
end