fix(index): Apply various fixes to the index engine (#12501)

This commit is contained in:
Carlos R. L. Rodrigues
2025-05-19 15:14:25 -03:00
committed by GitHub
parent 32be40a2c0
commit 59bbff62d8
20 changed files with 194 additions and 133 deletions
@@ -237,12 +237,7 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
): Promise<IndexTypes.QueryResultSet<TEntry>> {
await this.#isReady_
const {
keepFilteredEntities,
fields = [],
filters = {},
joinFilters = {},
} = config
const { fields = [], filters = {}, joinFilters = {} } = config
const { take, skip, order: inputOrderBy = {} } = config.pagination ?? {}
const select = normalizeFieldsSelection(fields)
@@ -281,7 +276,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
options: {
skip,
take,
keepFilteredEntities,
orderBy,
},
rawConfig: config,
@@ -290,7 +284,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
const { sql, sqlCount } = qb.buildQuery({
hasPagination,
returnIdOnly: !!keepFilteredEntities,
hasCount,
})
@@ -310,30 +303,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
} as IndexTypes.QueryFunctionReturnPagination)
: undefined
if (keepFilteredEntities) {
const mainEntity = Object.keys(select)[0]
const ids = resultSet.map((r) => r[`${mainEntity}.id`])
if (ids.length) {
const result = await this.query<TEntry>(
{
fields,
joinFilters,
filters: {
[mainEntity]: {
id: ids,
},
},
pagination: undefined,
keepFilteredEntities: false,
} as IndexTypes.IndexQueryConfig<TEntry>,
sharedContext
)
result.metadata ??= resultMetadata
return result
}
}
return {
data: qb.buildObjectFromResultset(
resultSet