Skip to content

Handle Pgvector itself in new/1 - #8

Merged
ankane merged 1 commit into
pgvector:masterfrom
nallwhy:handle_itself_with_new
Sep 3, 2023
Merged

Handle Pgvector itself in new/1#8
ankane merged 1 commit into
pgvector:masterfrom
nallwhy:handle_itself_with_new

Conversation

@nallwhy

@nallwhynallwhy commented Sep 3, 2023

Copy link
Copy Markdown
Contributor

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

**(FunctionClauseError)nofunctionclausematchinginPgvector.new/1ThefollowingargumentsweregiventoPgvector.new/1:
# 1
Pgvector.new([...])Attemptedfunctionclauses(showing2outof2):
defnew(list)whenis_list(list)defnew(tensor)whenis_struct(tensor,Nx.Tensor)(pgvector0.2.0) lib/pgvector.ex:11: Pgvector.new/1(pgvector0.2.0) lib/pgvector/ecto/vector.ex:8: Pgvector.Ecto.Vector.cast/1(ecto3.10.3) lib/ecto/changeset.ex:814: Ecto.Changeset.cast_field/9(ecto3.10.3) lib/ecto/changeset.ex:766: Ecto.Changeset.process_param/9(elixir1.15.4) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3(ecto3.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:masterSep 3, 2023
@ankane

Copy link
Copy Markdown
Member

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

Sign up for freeto 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

@nallwhy@ankane@josevalim