mirror of
https://github.com/strapi/strapi.git
synced 2026-01-07 12:45:45 +00:00
Wrap tsvector attributes with coalesce before join
Fixed a bug where joining multiple tsvector attributes results in NULL because one of the columns contains NULL. The expected behaviour is to ignore that column instead, which is achieved by setting it to an empty string
This commit is contained in:
parent
23eb263e07
commit
fcdbc4fbe3
@ -546,8 +546,8 @@ const buildSearchQuery = (qb, model, params) => {
|
||||
case 'pg': {
|
||||
const searchQuery = searchText.map(attribute =>
|
||||
_.toLower(attribute) === attribute
|
||||
? `to_tsvector(${attribute})`
|
||||
: `to_tsvector("${attribute}")`
|
||||
? `to_tsvector(coalesce(${attribute}, ''))`
|
||||
: `to_tsvector(coalesce("${attribute}", ''))`
|
||||
);
|
||||
|
||||
qb.orWhereRaw(`${searchQuery.join(' || ')} @@ plainto_tsquery(?)`, query);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user