@remit/drizzle-service 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -178,6 +178,60 @@ describe("DrizzleThreadMessageRepository (sqlite)", () => {
|
|
|
178
178
|
);
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
+
const operatorCases = [
|
|
182
|
+
{
|
|
183
|
+
term: "a OR b",
|
|
184
|
+
matching: ["a OR b literal"],
|
|
185
|
+
other: ["a alone", "b alone"],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
term: "NOT x",
|
|
189
|
+
matching: ["NOT x here"],
|
|
190
|
+
other: ["x alone", "y alone"],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
term: "NEAR(a b)",
|
|
194
|
+
matching: ["NEAR a b together"],
|
|
195
|
+
other: ["a then b", "a b"],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
term: '"',
|
|
199
|
+
matching: ['say "hi"'],
|
|
200
|
+
other: ["plain words"],
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
term: "*",
|
|
204
|
+
matching: ["2 * 3"],
|
|
205
|
+
other: ["plain words"],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
term: "subject:x",
|
|
209
|
+
matching: ["subject x notes"],
|
|
210
|
+
other: ["x alone", "plain words"],
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
term: "^x",
|
|
214
|
+
matching: ["x alone"],
|
|
215
|
+
other: ["y alone", "plain words"],
|
|
216
|
+
},
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
for (const { term, matching, other } of operatorCases) {
|
|
220
|
+
test(`search treats ${JSON.stringify(term)} as literal text, not FTS5 syntax`, async () => {
|
|
221
|
+
const mailboxId = `mbx-operators-${Math.random().toString(36).slice(2)}`;
|
|
222
|
+
for (const subject of [...matching, ...other]) {
|
|
223
|
+
await repo.create(makeInput({ mailboxId, subject }));
|
|
224
|
+
}
|
|
225
|
+
const result = await repo.searchByMailbox(
|
|
226
|
+
ACCOUNT,
|
|
227
|
+
mailboxId,
|
|
228
|
+
{ subject: term },
|
|
229
|
+
{ count: 50 },
|
|
230
|
+
);
|
|
231
|
+
assert.deepEqual(result.items.map((i) => i.subject).sort(), matching);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
181
235
|
test("countByMailbox counts matches under the same predicate", async () => {
|
|
182
236
|
const n = await repo.countByMailbox(ACCOUNT, MAILBOX, {
|
|
183
237
|
subject: "invoice",
|