Skip to content

Commit 360626a

Browse files
committed
fix: type cast errors w/ floats & vectors
1 parent 9fd0502 commit 360626a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/ash/type/float.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ defmodule Ash.Type.Float do
107107
end
108108

109109
@impl true
110+
def cast_input(nil, _), do: {:ok, nil}
111+
110112
def cast_input(value, _) do
111113
Ecto.Type.cast(:float, value)
112114
end

lib/ash/vector.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ defmodule Ash.Vector do
2626
dim = list |> length()
2727
bin = for v <- list, into: "", do: <<v::float-32>>
2828

29-
{:ok, %Ash.Vector{data: bin, dimensions: dim}}
29+
{:ok, %Ash.Vector{data: <<dim::unsigned-16, 0::unsigned-16>> <> bin, dimensions: dim}}
3030
rescue
31-
_ -> {:error, :invalid_vector}
31+
_ ->
32+
{:error, :invalid_vector}
3233
end
3334

3435
@doc """

0 commit comments

Comments
 (0)