From c8d7ff3d4ccd54f4f7275e368bd39c238407c26e Mon Sep 17 00:00:00 2001 From: Sid Ferreira <143615+sidferreira@users.noreply.github.com> Date: Sun, 4 Apr 2021 22:03:06 -0700 Subject: [PATCH] FTS: Rebase + fix tests --- src/QueryDescription/index.js | 3 ++- src/QueryDescription/test.js | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/QueryDescription/index.js b/src/QueryDescription/index.js index 59cbf5f2b..b2eccc5fa 100644 --- a/src/QueryDescription/index.js +++ b/src/QueryDescription/index.js @@ -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 { diff --git a/src/QueryDescription/test.js b/src/QueryDescription/test.js index 7601316da..65cfe4e54 100644 --- a/src/QueryDescription/test.js +++ b/src/QueryDescription/test.js @@ -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: [], }) }) })