Compare commits

...

2 Commits

Author SHA1 Message Date
Apoorv Mishra e54a35a2f3 fix: test 2024-07-26 22:25:50 +05:30
Apoorv Mishra e330be11f3 fix: tsquery err 2024-07-26 21:49:27 +05:30
2 changed files with 25 additions and 1 deletions
@@ -486,6 +486,25 @@ describe("SearchHelper", () => {
);
expect(totalCount).toBe(1);
});
test("should correctly handle removal of trailing spaces", async () => {
const team = await buildTeam();
const user = await buildUser({ teamId: team.id });
const collection = await buildCollection({
teamId: team.id,
userId: user.id,
});
const document = await buildDocument({
teamId: team.id,
userId: user.id,
collectionId: collection.id,
text: "env: some env",
});
document.title = "change";
await document.save();
const { totalCount } = await SearchHelper.searchForUser(user, "env: ");
expect(totalCount).toBe(1);
});
});
describe("#searchTitlesForUser", () => {
+6 -1
View File
@@ -555,7 +555,12 @@ export default class SearchHelper {
}
return (
queryParser()(quotedSearch ? limitedQuery : `${limitedQuery}*`)
queryParser()(
// Although queryParser trims the query, looks like there's a
// bug for certain cases where it removes other characters in addition to
// spaces. Ref: https://github.com/caub/pg-tsquery/issues/27
quotedSearch ? limitedQuery.trim() : `${limitedQuery.trim()}*`
)
// Remove any trailing join characters
.replace(/&$/, "")
);