Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(order): populate version entities #8884

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/modules/order/src/utils/base-repository-find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ export function setFindMethods<T>(klass: Constructor<T>, entity: any) {
config.options ??= {}
config.options.populate ??= []

const strategy = config.options.strategy ?? LoadStrategy.JOINED
let orderAlias = "o0"
if (isRelatedEntity) {
if (entity === OrderClaim) {
if (
config.options.populate.includes("additional_items") &&
!config.options.populate.includes("claim_items")
) {
config.options.populate.push("claim_items")
}
config.options.populate.push("claim_items")
}

if (strategy === LoadStrategy.JOINED) {
config.options.populate.push("order.shipping_methods")
config.options.populate.push("order.summary")
config.options.populate.push("shipping_methods")
}

if (!config.options.populate.includes("order.items")) {
Expand All @@ -60,7 +62,7 @@ export function setFindMethods<T>(klass: Constructor<T>, entity: any) {
}

let defaultVersion = knex.raw(`"${orderAlias}"."version"`)
const strategy = config.options.strategy ?? LoadStrategy.JOINED

if (strategy === LoadStrategy.SELECT_IN) {
const sql = manager
.qb(Order, "_sub0")
Expand All @@ -82,7 +84,6 @@ export function setFindMethods<T>(klass: Constructor<T>, entity: any) {
popWhere.order ??= {}

popWhere.shipping_methods ??= {}
popWhere.shipping_methods.version = version
popWhere.shipping_methods.deleted_at ??= null

popWhere.shipping_methods.shipping_method ??= {}
Expand Down
Loading