From fba23424f42cb8c8bc8bf46fe35d7f260f3298c4 Mon Sep 17 00:00:00 2001 From: Dheeraj Bhaskaruni Date: Wed, 15 Apr 2026 13:50:32 -0500 Subject: [PATCH] fix: use literal values in SET commands for pg8000 compatibility PostgreSQL SET commands do not support bind parameters (parameterized queries). While psycopg2 silently works around this limitation, pg8000 raises a syntax error when encountering bind parameters in SET statements. Replace bindparams usage with f-string interpolation for the ivfflat.probes and hnsw.ef_search SET LOCAL commands. This is safe because both values are already validated as integers before this point. Fixes #112 --- src/vecs/collection.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/vecs/collection.py b/src/vecs/collection.py index eab8f93..c4d3214 100644 --- a/src/vecs/collection.py +++ b/src/vecs/collection.py @@ -555,15 +555,14 @@ def query( with self.client.Session() as sess: with sess.begin(): - # index ignored if greater than n_lists - sess.execute( - text("set local ivfflat.probes = :probes").bindparams(probes=probes) - ) + # PostgreSQL SET commands do not support bind parameters, + # which causes errors with some drivers (e.g. pg8000). + # Using literal integers is safe here since probes and + # ef_search are already validated as integers above. + sess.execute(text(f"set local ivfflat.probes = {int(probes)}")) if self.client._supports_hnsw(): sess.execute( - text("set local hnsw.ef_search = :ef_search").bindparams( - ef_search=ef_search - ) + text(f"set local hnsw.ef_search = {int(ef_search)}") ) if len(cols) == 1: return [str(x) for x in sess.scalars(stmt).fetchall()]