Bit objects not supported with Psycopg 2 and pg8000
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by reading the existing HalfvecAdapter and register_out_adapter patterns, then check how Vector, HalfVector, and SparseVector adapters are tested for Psycopg 2 and pg8000. Add equivalent text adaptation for Bit in both drivers; done when the two query examples accept Bit('101') and the pg8000 value is handled as the intended bit string.
Written by the indexing model from the issue text.
Description
Hi, pgvector.Bit works as a query parameter with Psycopg 3 (it registers a dumper), but not with Psycopg 2 or pg8000:
cur.execute('SELECT %s::bit(3)', (Bit('101'),)) # psycopg2: ProgrammingError: can't adapt type 'Bit'
conn.run('SELECT CAST(:b AS bit(3))', b=Bit('101')) # pg8000: "i" is not a valid binary digit
Passing to_text() works, but it's inconsistent with Vector/HalfVector/SparseVector, which both drivers adapt. The pg8000 case is a bit worse since it sends the wrong value rather than raising a clear error.
For both drivers this is a small text adapter (same pattern as HalfvecAdapter / register_out_adapter); happy to open a PR if you'd like. (asyncpg left out on purpose, per #110.)
Tested with main (b5d9b70), Postgres 17, pgvector master.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 100
- Avg merge
- 13m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pgvector/pgvector-python
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
pgvector/pgvector-python#168 ·
All issues in pgvector/pgvector-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from gitPossibly taken @MohabMohie claimed this today. Openagentic
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
huggingface/smolagents#3045 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day