fix: fix weight/length/height/width types in updates (#12500)
This commit is contained in:
@@ -21,6 +21,8 @@ export class ProductRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
|
||||
) => void,
|
||||
context: Context = {}
|
||||
): Promise<InferEntityType<typeof Product>[]> {
|
||||
updates.forEach((update) => this.correctUpdateDTOTypes(update))
|
||||
|
||||
const products = await this.find(
|
||||
buildQuery({ id: updates.map((p) => p.id) }, { relations: ["*"] }),
|
||||
context
|
||||
@@ -80,6 +82,15 @@ export class ProductRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
|
||||
.filter((product) => product !== undefined)
|
||||
}
|
||||
|
||||
// We should probably fix the column types in the database to avoid this
|
||||
// It would also match the types in ProductVariant, which are already numbers
|
||||
protected correctUpdateDTOTypes(update: any) {
|
||||
update.weight = update.weight?.toString()
|
||||
update.length = update.length?.toString()
|
||||
update.height = update.height?.toString()
|
||||
update.width = update.width?.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* In order to be able to have a strict not in categories, and prevent a product
|
||||
* to be return in the case it also belongs to other categories, we need to
|
||||
|
||||
Reference in New Issue
Block a user