Skip to content

Conversation

@nallwhy
Copy link
Contributor

@nallwhy nallwhy commented Sep 3, 2023

If you try to take Pgvector from A and update it in B, you will get the following error.

** (FunctionClauseError) no function clause matching in Pgvector.new/1    
    
    The following arguments were given to Pgvector.new/1:
    
        # 1
        Pgvector.new([...])
    
    Attempted function clauses (showing 2 out of 2):
    
        def new(list) when is_list(list)
        def new(tensor) when is_struct(tensor, Nx.Tensor)
    
    (pgvector 0.2.0) lib/pgvector.ex:11: Pgvector.new/1
    (pgvector 0.2.0) lib/pgvector/ecto/vector.ex:8: Pgvector.Ecto.Vector.cast/1
    (ecto 3.10.3) lib/ecto/changeset.ex:814: Ecto.Changeset.cast_field/9
    (ecto 3.10.3) lib/ecto/changeset.ex:766: Ecto.Changeset.process_param/9
    (elixir 1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto 3.10.3) lib/ecto/changeset.ex:744: Ecto.Changeset.cast/6

Since Elixir primitives like URI can receive themselves as a parameter of new function, Pgvector does the same thing.

@ankane ankane merged commit 0207fcb into pgvector:master Sep 3, 2023
@ankane
Copy link
Member

ankane commented Sep 3, 2023

Awesome, thanks @nallwhy! (and thanks @josevalim for the review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants