Allow multiple default columns #2

Merged
bilal.catic merged 5 commits from allow-multiple-default-columns into join-bug-fix-with-multiple-default-columns 2020-04-24 11:28:06 +02:00
Showing only changes of commit 18f6875b54 - Show all commits

View File

@@ -47,6 +47,20 @@ describe PgSearchable do
expect(VectorModel.scope_search("#{record2.id}")).to contain_exactly(record2)
end
it 'can search multiple default columns if no column name is used with single search term' do
records = VectorModelWithTwoDefaultColumns.create [{ name: 'hamo', value: '5' }, { name: 'meho', value: '20 hamo' }, { name: 'munja-5', value: '300' }]
expect(VectorModelWithTwoDefaultColumns.scope_search('name:hamo')).to contain_exactly(records[0])
expect(VectorModelWithTwoDefaultColumns.scope_search('hamo')).to contain_exactly(records[0], records[1])
expect(VectorModelWithTwoDefaultColumns.scope_search('5')).to contain_exactly(records[0], records[2])
end
it 'can search multiple default columns if no column name is used in query containing multiple search terms' do
records = VectorModelWithTwoDefaultColumns.create [{ name: 'hamo', value: '9' }, { name: 'meho', value: '5' }, { name: 'oko-9', value: '100' }]
expect(VectorModelWithTwoDefaultColumns.scope_search('(9 and not name:hamo) or meho')).to contain_exactly(records[2], records[1])
end
it 'searches column declared in search term' do
record1 = VectorModel.create name: 'hamo', value: '-45'
record2 = VectorModel.create name: 'meho', value: '120'
@@ -144,8 +158,6 @@ describe PgSearchable do
expect(DynamicModelWithTagValues.scope_search('tag:green or value:"not"')).to contain_exactly(record1, record2)
end
it 'can search in referenced column and in model columns with multiple search terms connected with logical operators' do
record1 = DynamicModelWithTagValues.create name: 'something', value: 'amazing'
record2 = DynamicModelWithTagValues.create name: 'new record', value: 'not so amazing'