fix(medusa): Only add ordering select if not already present (#3319)

This commit is contained in:
Philip Korsholm
2023-02-26 13:08:06 +01:00
committed by GitHub
parent 6323868f65
commit 08c8aa46c5
3 changed files with 151 additions and 85 deletions

View File

@@ -16,13 +16,17 @@ export function getListQuery(
const inventoryItemRepository = manager.getRepository(InventoryItem)
const { q, ...selectorRest } = selector
const query = buildQuery(selectorRest, config) as ExtendedFindConfig<InventoryItem> & {
where: FindOptionsWhere<InventoryItem & {
location_id?: string
}>
const query = buildQuery(
selectorRest,
config
) as ExtendedFindConfig<InventoryItem> & {
where: FindOptionsWhere<
InventoryItem & {
location_id?: string
}
>
}
const queryBuilder = inventoryItemRepository.createQueryBuilder("inv_item")
if (q) {
@@ -65,7 +69,9 @@ export function getListQuery(
const toSelect: string[] = []
const parsed = Object.entries(query.order).reduce((acc, [k, v]) => {
const key = `inv_item.${k}`
toSelect.push(key)
if (!query.select?.[k]) {
toSelect.push(key)
}
acc[key] = v
return acc
}, {})