[object Object]

← back to Wallco Ai

seamless-bg-swap: fix RETURNING-id parse (psql -At emits command tag; [-1] grabbed 'INSERT 0 1' leaving image_url __NEW__) — proven on #39341 child #57712 + full-PASS #57685 child #57713

7c1a338fc4c87bb42d7f5ad1e9fa8d3d3b155882 · 2026-06-09 13:12:11 -0700 · Steve Abrams

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Files touched

Diff

commit 7c1a338fc4c87bb42d7f5ad1e9fa8d3d3b155882
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jun 9 13:12:11 2026 -0700

    seamless-bg-swap: fix RETURNING-id parse (psql -At emits command tag; [-1] grabbed 'INSERT 0 1' leaving image_url __NEW__) — proven on #39341 child #57712 + full-PASS #57685 child #57713
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---
 scripts/seamless-bg-swap.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/seamless-bg-swap.py b/scripts/seamless-bg-swap.py
index e7ec566..9d373dd 100644
--- a/scripts/seamless-bg-swap.py
+++ b/scripts/seamless-bg-swap.py
@@ -350,8 +350,11 @@ VALUES
    {arr_lit(d.get('motifs'), 'text')}, {arr_lit(d.get('tags'), 'text')},
    {esc(d.get('category'))}, FALSE, {args.id})
 RETURNING id;"""
-        new_id = psql(ins_sql)
-        new_id = new_id.strip().splitlines()[-1].strip() if new_id else ''
+        raw = psql(ins_sql)
+        # psql -At prints the RETURNING row AND the "INSERT 0 1" command tag —
+        # pick the line that is actually a bare integer (taking [-1] grabbed the
+        # tag and left image_url='__NEW__'; hit on first #39341 run, child #57712).
+        new_id = next((ln.strip() for ln in (raw or '').splitlines() if ln.strip().isdigit()), '')
         if new_id.isdigit():
             psql(f"UPDATE spoon_all_designs SET image_url='/designs/img/by-id/{new_id}' WHERE id={new_id};")
             print(f'· inserted child #{new_id}  (is_published=FALSE, parent={args.id})')

← b449bb8 home hero: slides click through to their design PDP (role=li  ·  back to Wallco Ai  ·  read-only settlement sweep over BLEED_GHOST cohort: 2,517 sw 7440b74 →