feat(F-066): completed feature
This commit is contained in:
@@ -655,6 +655,9 @@ function serializeProduct(product: Product, images: ProductImage[] = []) {
|
||||
images: images.map(serializeImage),
|
||||
description: product.description,
|
||||
state: product.state,
|
||||
channels: product.channels,
|
||||
featured: product.featured,
|
||||
attributes: product.attributes,
|
||||
seoTitle: product.seoTitle,
|
||||
seoDescription: product.seoDescription,
|
||||
categoryIds: product.categoryIds,
|
||||
|
||||
@@ -121,8 +121,16 @@ export class PgProductRepository implements ProductRepository {
|
||||
const values: unknown[] = [];
|
||||
for (const [key, column] of UPDATABLE) {
|
||||
if (key in patch) {
|
||||
values.push(patch[key]);
|
||||
setClauses.push(`${column} = $${values.length}`);
|
||||
// The `attributes` column is JSONB; pg-node would otherwise serialise
|
||||
// JS arrays as PG array literals (`{bio,keto}`) which the JSONB parser
|
||||
// rejects. Stringify explicitly and cast to JSONB.
|
||||
if (key === 'attributes' && Array.isArray(patch[key])) {
|
||||
values.push(JSON.stringify(patch[key]));
|
||||
setClauses.push(`${column} = $${values.length}::jsonb`);
|
||||
} else {
|
||||
values.push(patch[key]);
|
||||
setClauses.push(`${column} = $${values.length}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user