Skip to content

Commit

Permalink
FTS: Rebase + fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sidferreira committed May 10, 2021
1 parent 06d4166 commit c8d7ff3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/QueryDescription/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ export function sanitizeLikeString(value: string): string {
}

export function textMatches(value: string): Comparison {
return { operator: 'match', right: { value } }
invariant(typeof value === 'string', 'Value passed to Q.textMatches() is not a string')
return { operator: 'match', right: { value }, type: comparisonSymbol }
}

export function column(name: ColumnName): ColumnDescription {
Expand Down
20 changes: 12 additions & 8 deletions src/QueryDescription/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,19 +637,23 @@ describe('queryWithoutDeleted', () => {
})

it('supports textMatches as fts join', () => {
const query = Q.buildQueryDescription([
Q.textMatches('searchable', 'hello world'),
])
const query = Q.buildQueryDescription([Q.where('searchable', Q.textMatches('hello world'))])
expect(query).toEqual({
'where': [
where: [
{
'operator': 'match',
'right': {
'value': 'searchable',
type: 'where',
left: 'searchable',
comparison: {
operator: 'match',
right: {
value: 'hello world',
},
},
},
],
'join': [],
joinTables: [],
nestedJoinTables: [],
sortBy: [],
})
})
})

0 comments on commit c8d7ff3

Please sign in to comment.