From 3ebb55264701a15140504c745f4f265c2c56279b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 7 Jul 2026 11:58:09 +0000 Subject: [PATCH] fix(stock): repair Flexoptix stock write path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs blocked all Flexoptix stock_observations: 1. db.ts: compatible_brands null param needs ::text[] cast; price_currency needs ::bpchar cast in stock_observations INSERT 2. flexoptix-api-sync.ts: UPDATE transceivers used $1 in WHERE IS NOT NULL clause without explicit type cast — PostgreSQL cant infer type of untyped null params in WHERE context. Fixed with $1::text / $2::text casts. Result: 346 stock observations written on first run after fix. --- packages/scraper/src/robots/flexoptix-api-sync.ts | 6 +++--- packages/scraper/src/utils/db.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/scraper/src/robots/flexoptix-api-sync.ts b/packages/scraper/src/robots/flexoptix-api-sync.ts index cb5c1ce..f180dcb 100644 --- a/packages/scraper/src/robots/flexoptix-api-sync.ts +++ b/packages/scraper/src/robots/flexoptix-api-sync.ts @@ -361,11 +361,11 @@ async function importProduct( if (product.imageUrl || product.url) { await pool.query(` UPDATE transceivers SET - image_url = COALESCE(NULLIF(image_url, ''), $1), - product_page_url = COALESCE(NULLIF(product_page_url, ''), $2), + image_url = COALESCE(NULLIF(image_url, ''), $1::text), + product_page_url = COALESCE(NULLIF(product_page_url, ''), $2::text), updated_at = NOW() WHERE id = $3 - AND ($1 IS NOT NULL OR $2 IS NOT NULL) + AND ($1::text IS NOT NULL OR $2::text IS NOT NULL) `, [product.imageUrl ?? null, product.url ?? null, transceiverId]); } diff --git a/packages/scraper/src/utils/db.ts b/packages/scraper/src/utils/db.ts index 903ca68..bc2b76a 100644 --- a/packages/scraper/src/utils/db.ts +++ b/packages/scraper/src/utils/db.ts @@ -461,8 +461,8 @@ export async function upsertStockObservation(params: { $5, $6::date, $7, $8::date, $9, $10::date, - $11, $12, $13, $14, $15, - $16, $17, $18, $19 + $11, $12, $13::text[], $14, $15, + $16, $17::bpchar, $18, $19 )`, [ params.transceiverId,