Add whereNotNull to count query sort-field EXISTS
The list CTE's INNER JOIN on search already excludes entities whose sort-field value is NULL (truncated long values stored as NULL by buildEntitySearch). Add the same whereNotNull to the count query's EXISTS so totalItems matches the reachable set. Matters for fields like metadata.description where ~128K entities have NULL values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -505,7 +505,8 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog {
|
||||
this.database('search')
|
||||
.select(this.database.raw(1))
|
||||
.whereRaw('search.entity_id = final_entities.entity_id')
|
||||
.where('search.key', sortField.field),
|
||||
.where('search.key', sortField.field)
|
||||
.whereNotNull('search.value'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user