You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 869f52c
Browse filesBrowse the repository at this point in the historyBrowse files
- Added `_string = String()` and implemented `BIT.literal_processor(self, dialect: Dialect)` using `self._string._cached_literal_processor(dialect)` while converting `pgvector.Bit` instances via `.to_text()`.
21
-
- Updated `BIT.process_bind_param` so `pgvector.Bit` instances are converted via `.to_text()` before `asyncpg.BitString` conversion or return.
20
+
- Added shared helper `BIT._to_text` normalizing `pgvector.Bit`, `str` subclasses (such as SQLAlchemy 2.1's `postgresql.BitString`), and `asyncpg.BitString` to plain `str` bit text.
21
+
- Added `_string = String()` and implemented `BIT.literal_processor(self, dialect: Dialect)` using `self._string._cached_literal_processor(dialect)` over `self._to_text(value)`.
22
+
- Updated `BIT.process_bind_param` to normalize inputs via `self._to_text(value)` before `asyncpg.BitString` conversion or return.
- Added regression assertions inside `TestSqlalchemy.test_literal_binds` verifying `compile_kwargs={'literal_binds': True}` for `'101'`, `Bit('101')`, `postgresql.BitString('101')`, `asyncpg.BitString('101')`, and `jaccard_distance('101')`.
25
+
- Expanded `TestSqlalchemy.test_bit` and `TestSqlalchemyAsync.test_bit` to verify persisting and reading back `Bit` instances across sync and async engines.
27
26
28
27
## Local Environment and Step-by-Step Execution (Windows + Docker)
29
28
@@ -59,14 +58,20 @@ Additionally, passing a `pgvector.Bit` instance directly into SQLAlchemy `BIT` b
59
58
```
60
59
61
60
4.**Run the full 581-test suite on Windows**
62
-
On Windows, Python's default `asyncio.ProactorEventLoop` is rejected by `psycopg` async connections (`psycopg.InterfaceError`). Running `pytest` with `WindowsSelectorEventLoopPolicy` enables all sync and async tests across all drivers and ORMs:
61
+
On Windows, Python's default `asyncio.ProactorEventLoop` is rejected by `psycopg` async connections (`psycopg.InterfaceError`). `tests/conftest.py` registers a `pytest_asyncio_loop_factories` hook on `win32` returning `asyncio.SelectorEventLoop`, so plain `pytest` passes all sync and async tests across every driver and ORM:
6.**Run the bulk loading example (`examples/loading/example.py`)**
70
75
```powershell
71
76
$env:PGHOST = "localhost"
72
77
$env:PGUSER = "bit"
@@ -79,6 +84,9 @@ Additionally, passing a `pgvector.Bit` instance directly into SQLAlchemy `BIT` b
79
84
| --- | --- | --- | --- |
80
85
| Offline unit tests |`pytest tests/test_bit.py tests/test_half_vector.py tests/test_sparse_vector.py tests/test_vector.py`|**122 passed** (`1.25s`) | Pure Python, NumPy, and SciPy vector/bit tests |
81
86
| Offline SQLAlchemy `BIT` compilation |`Item.binary_embedding.hamming_distance('101' / Bit('101'))` & `jaccard_distance('101')` with `literal_binds=True`|**Passed**| Compiled cleanly to `<~> '101'` and `<%%> '101'`|
82
-
| Full suite (default Windows event loop) |`.\.venv\Scripts\python.exe -m pytest`|**568 passed, 13 failed** (`67.54s`) | All 13 failures were `psycopg` async tests due to Windows default `ProactorEventLoop`|
83
-
| Full suite (`WindowsSelectorEventLoopPolicy`) |`pytest.main()` with `WindowsSelectorEventLoopPolicy`|**581 passed** (`25.43s`) | All 12 test modules passed (`asyncpg`, `bit`, `django`, `half_vector`, `peewee`, `pg8000`, `psycopg`, `psycopg2`, `sparse_vector`, `sqlalchemy`, `sqlmodel`, `vector`) |
87
+
| Full suite (before `conftest.py` hook) |`.\.venv\Scripts\python.exe -m pytest`|**568 passed, 13 failed** (`67.54s`) | Baseline before adding `SelectorEventLoop` hook; all 13 failures were `psycopg` async under `ProactorEventLoop`|
88
+
| Full suite (with `conftest.py``SelectorEventLoop` hook) |`.\.venv\Scripts\python.exe -m pytest`|**581 passed**| All 12 test modules passed (`asyncpg`, `bit`, `django`, `half_vector`, `peewee`, `pg8000`, `psycopg`, `psycopg2`, `sparse_vector`, `sqlalchemy`, `sqlmodel`, `vector`) |
89
+
| Type check (`mypy`) |`.\.venv\Scripts\python.exe -m mypy`|**Passed** (`0` issues) |`Success: no issues found in 54 source files`|
90
+
| Linter (`pycodestyle`) |`.\.venv\Scripts\python.exe -m pycodestyle . --ignore=E501,E704,W504 --exclude=.venv`|**Passed** (`0` issues) | Clean across codebase and tests |
91
+
| Type check (`ty`) |`.\.venv\Scripts\ty.exe check`|**21 diagnostics**| All 21 in upstream `tests/test_sqlmodel.py` (`sqlmodel 0.0.50` tuple inference); 0 in `pgvector/` or modified test files |
84
92
| Bulk loading example |`.\.venv\Scripts\python.exe examples\loading\example.py`|**Success**| Loaded `1000000` 128-dimensional vector rows via binary `COPY` into `pgvector_example`|
On Windows with Docker Desktop (`pgvector/pgvector:pg17`), start PostgreSQL and run the full suite with `WindowsSelectorEventLoopPolicy` (required for `psycopg` async tests on Windows):
849
+
On Windows with Docker Desktop (`pgvector/pgvector:pg17`), start PostgreSQL and run the full test suite (`tests/conftest.py` automatically configures `SelectorEventLoop` on Windows for `psycopg` async tests):
@@ -874,8 +874,9 @@ For full technical context, implementation notes, and verified test/example outp
874
874
### Specific Changes in this Repository
875
875
-**SQLAlchemy `BIT` literal binds and object support (`pgvector/sqlalchemy/bit.py`)**:
876
876
- Implemented `literal_processor` for `BIT` in SQLAlchemy to support compiling queries with `compile_kwargs={'literal_binds': True}`. Previously, while `VECTOR`, `HALFVEC`, and `SPARSEVEC` implemented `literal_processor`, `BIT` inherited the default from `PGBit` (which returns `None`), causing `sqlalchemy.exc.CompileError: No literal value renderer is available for literal value "'101'" with datatype BIT`.
877
-
- Added support in `BIT.process_bind_param` and `BIT.literal_processor` for `pgvector.Bit` instances by converting them to bit string text, allowing `Bit` objects to be passed cleanly across SQLAlchemy queries and expressions.
878
-
- Added regression test assertions to `test_literal_binds` in `tests/test_sqlalchemy.py`.
879
-
-**Context, Verification, and Documentation (`CONTEXT_AND_RESULTS.md`, `README.md`)**:
880
-
- Verified all **581 tests** pass against `pgvector/pgvector:pg17` (including all sync/async driver and ORM suites when using `WindowsSelectorEventLoopPolicy` on Windows) and verified `examples/loading/example.py` loading 1,000,000 rows into PostgreSQL.
877
+
- Added shared normalization (`BIT._to_text`) in `BIT.process_bind_param` and `BIT.literal_processor` for `pgvector.Bit`, `postgresql.BitString` (SQLAlchemy >= 2.1), and `asyncpg.BitString` instances by converting them to plain bit string text, allowing `Bit` and dialect `BitString` objects to be passed cleanly across SQLAlchemy queries and literal-bind expressions.
878
+
- Added regression test assertions to `test_literal_binds`, `TestSqlalchemy.test_bit`, and `TestSqlalchemyAsync.test_bit` in `tests/test_sqlalchemy.py`.
879
+
-**Context, Verification, and Documentation (`CONTEXT_AND_RESULTS.md`, `README.md`, `tests/conftest.py`)**:
880
+
- Added a Windows-only `pytest_asyncio_loop_factories` hook in `tests/conftest.py` so plain `pytest` uses `SelectorEventLoop` on Windows.
881
+
- Verified all **581 tests** pass against `pgvector/pgvector:pg17` (plus `mypy` and `pycodestyle` clean) and verified `examples/loading/example.py` loading 1,000,000 rows into PostgreSQL.
0 commit comments