Skip to content

Commit 057806e

Browse files
committed
Added test for bit type with SQLAlchemy and asyncpg - #110
1 parent 230fe85 commit 057806e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_sqlalchemy.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,3 +526,20 @@ def connect(dbapi_connection, connection_record):
526526
assert item.embeddings[1].tolist() == [4, 5, 6]
527527

528528
await engine.dispose()
529+
530+
@pytest.mark.asyncio
531+
@pytest.mark.skipif(sqlalchemy_version == 1, reason='Requires SQLAlchemy 2+')
532+
async def test_asyncpg_bit(self):
533+
import asyncpg
534+
535+
engine = create_async_engine('postgresql+asyncpg://localhost/pgvector_python_test')
536+
async_session = async_sessionmaker(engine, expire_on_commit=False)
537+
538+
async with async_session() as session:
539+
async with session.begin():
540+
embedding = asyncpg.BitString('101')
541+
session.add(Item(id=1, binary_embedding=embedding))
542+
item = await session.get(Item, 1)
543+
assert item.binary_embedding == embedding
544+
545+
await engine.dispose()

0 commit comments

Comments
 (0)