From 3c69e7545abf7f569193b165e2d6f94eacb2e692 Mon Sep 17 00:00:00 2001 From: nickviljoen Date: Wed, 29 Apr 2026 11:47:21 +0200 Subject: [PATCH] Fix: Escape literal % in LIKE pattern in B1 metadata diagnostic psycopg2 performs %-substitution when params are passed to execute(), so 'M%' in the LIKE clause was being interpreted as a positional placeholder, raising IndexError when there's only one real %s (LIMIT). Escape as 'M%%' so it's preserved as a literal percent. Co-Authored-By: Claude Opus 4.7 (1M context) --- Python-Version/scripts/diagnose_b1_master_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python-Version/scripts/diagnose_b1_master_metadata.py b/Python-Version/scripts/diagnose_b1_master_metadata.py index 808713a..ab27e02 100644 --- a/Python-Version/scripts/diagnose_b1_master_metadata.py +++ b/Python-Version/scripts/diagnose_b1_master_metadata.py @@ -55,7 +55,7 @@ def main(): cursor.execute(""" SELECT tracking_id, original_filename, full_metadata FROM master_assets - WHERE tracking_id LIKE 'M%' + WHERE tracking_id LIKE 'M%%' AND local_campaign_id IS NULL AND status = 'active' ORDER BY created_at DESC