Skip to content

Commit 8885197

Browse files
committed
Added example of getting items within a certain distance with SQLAlchemy ORM
1 parent 57226ca commit 8885197

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/test_sqlalchemy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ def test_filter(self):
111111
items = session.query(Item).filter(Item.embedding.l2_distance([1, 1, 1]) < 1).all()
112112
assert [v.id for v in items] == [1]
113113

114+
def test_filter_orm(self):
115+
create_items()
116+
with Session(engine) as session:
117+
items = session.scalars(select(Item).filter(Item.embedding.l2_distance([1, 1, 1]) < 1))
118+
assert [v.id for v in items] == [1]
119+
114120
def test_select(self):
115121
with Session(engine) as session:
116122
session.add(Item(embedding=[2, 3, 3]))

0 commit comments

Comments
 (0)