fix(stock): repair Flexoptix stock write path
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.
This commit is contained in:
parent
73ad10f1a6
commit
3ebb552647
@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user