add tests to sql generator for keyword detection
This commit is contained in:
@@ -57,5 +57,10 @@ describe TextToSqlQuery do
|
||||
# tests complex query
|
||||
it { expect(described_class.new('(device_id:"with space" tags:mta no-quotes-id-123) or "id with quotes-5" and ( ("id with q 10" or "id with q 20") and ("id with Q 30" "id with Q 40") and not id-without-Q-50)', [:'players.name', :'players.value', :'players.device_id'], :"players.device_id", { tags: 'tags.name' }).where_clause).to eq(['((players.device_id ILIKE ? OR (tags.name ILIKE ? OR players.device_id ILIKE ?)) OR (players.device_id ILIKE ? AND (((players.device_id ILIKE ? OR players.device_id ILIKE ?) AND (players.device_id ILIKE ? OR players.device_id ILIKE ?)) AND NOT players.device_id ILIKE ?)))', '%with space%', '%mta%', '%no-quotes-id-123%', '%id with quotes-5%', '%id with q 10%', '%id with q 20%', '%id with Q 30%', '%id with Q 40%', '%id-without-Q-50%']) }
|
||||
|
||||
# tests query with multiple search terms with mixed and-or-not after dash and underscore
|
||||
it { expect(described_class.new('123-and-456 -or-2 -not_not_1', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id').where_clause).to eq(['(players.device_id ILIKE ? OR (players.device_id ILIKE ? OR players.device_id ILIKE ?))', '%123-and-456%', '%-or-2%', '%-not\_not\_1%'])}
|
||||
|
||||
# tests query with multiple search terms with mixed and-or-not after dash and underscore
|
||||
it { expect(described_class.new('andrew or ornela', [:'players.title', :'players.tag', :'players.device_id'], :'players.device_id').where_clause).to eq(['(players.device_id ILIKE ? OR players.device_id ILIKE ?)', '%andrew%', '%ornela%'])}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user