Handle Pgvector itself in new/1 by nallwhy · Pull Request #8 · pgvector/pgvector-elixir

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.