Skip to content

Commit

Permalink
Added test for Sequel
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jun 3, 2023
1 parent c363d24 commit 9563bd8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gemspec
gem "rake"
gem "minitest"
gem "pg"
gem "sequel"
27 changes: 27 additions & 0 deletions test/sequel_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require_relative "test_helper"

DB = Sequel.connect("postgres://localhost/pgvector_ruby_test")

DB.drop_table? :sequel_items
DB.create_table :sequel_items do
primary_key :id
column :embedding, "vector(3)"
end

class TestSequel < Minitest::Test
def setup
items.delete
end

def test_works
items.insert(embedding: "[1,1,1]")
items.insert(embedding: "[2,2,2]")
items.insert(embedding: "[1,1,2]")
results = items.order(Sequel.lit("embedding <-> '[1,1,1]'")).limit(5).all
assert_equal [1, 3, 2], results.map { |r| r[:id] }
end

def items
DB[:sequel_items]
end
end

0 comments on commit 9563bd8

Please sign in to comment.