fix(media-diff): pass SQL via stdin to avoid newline escaping issues in query_db_media_refs

This commit is contained in:
Lars committed 2026-10-29 18:20:21 +01:00
1 parent 0283fa196a
commit a17afb4b13
1 file changed
+3 -4
+3 -4
View File
@@ -82,12 +82,11 @@ def query_db_media_refs(tcfg):
"""
proc = subprocess.run(
[
'docker', 'exec', tcfg['db_container'],
'docker', 'exec', '-i', tcfg['db_container'],
'sh', '-ec',
'export PGPASSWORD="${POSTGRES_PASSWORD:-}"; '
f'psql -U "{tcfg["db_user"]}" -d "{tcfg["db_name"]}" -At -c ' + json.dumps(sql),
f'export PGPASSWORD="${{POSTGRES_PASSWORD:-}}"; exec psql -U "{tcfg["db_user"]}" -d "{tcfg["db_name"]}" -At',
],
capture_output=True, text=True, timeout=30,
input=sql, capture_output=True, text=True, timeout=30,
)
if proc.returncode != 0:
raise RuntimeError(f'Database media query failed: {proc.stderr.strip()}')