feat(F-066): completed feature

This commit is contained in:
chattie
2026-08-19 17:22:39 +02:00
parent e60e22ca30
commit 9f1858f6d7
10 changed files with 256 additions and 30 deletions

View File

@@ -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,

View File

@@ -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}`);
}
}
}