fixes on search (#11955)

In this PR
- enable search by email
- search with ' ' (spaces) string and special characters do not throw
entry error

closes https://github.com/twentyhq/twenty/issues/11447 &
https://github.com/twentyhq/core-team-issues/issues/860
This commit is contained in:
Etienne
2025-05-12 10:59:10 +02:00
committed by GitHub
parent 650f8f5963
commit ca6e979ead
8 changed files with 104 additions and 22 deletions

View File

@ -30,15 +30,8 @@ describe('getTsVectorColumnExpressionFromFields', () => {
const result = getTsVectorColumnExpressionFromFields(fields);
const expected = `
to_tsvector('simple', COALESCE("nameFirstName", '') || ' ' || COALESCE("nameLastName", '') || ' ' || COALESCE("jobTitle", '') || ' ' ||
COALESCE(
replace(
"emailsPrimaryEmail",
'@',
' '
),
''
)
)
COALESCE("emailsPrimaryEmail", '') || ' ' ||
COALESCE(SPLIT_PART("emailsPrimaryEmail", '@', 2), ''))
`.trim();
expect(result.trim()).toBe(expected);

View File

@ -82,15 +82,9 @@ const getColumnExpression = (
switch (fieldType) {
case FieldMetadataType.EMAILS:
return `
COALESCE(
replace(
${quotedColumnName},
'@',
' '
),
''
)
`;
COALESCE(${quotedColumnName}, '') || ' ' ||
COALESCE(SPLIT_PART(${quotedColumnName}, '@', 2), '')`;
default:
return `COALESCE(${quotedColumnName}, '')`;
}