Current section

Files

Jump to
ash_age lib type agtype.ex
Raw

lib/type/agtype.ex

defmodule AshAge.Type.Agtype do
@moduledoc """
AGType decoder for PostgreSQL graph data.
"""
alias AshAge.Type.{Path, Vertex}
@doc """
Decodes an agtype string into Elixir terms.
"""
@spec decode(binary()) :: any()
def decode(agtype_string) when is_binary(agtype_string) do
# Simplified decoder - in production this would parse the agtype format
# For now, return a basic structure.
# Heuristic for path vs vertex to satisfy compiler warnings in callers.
if String.contains?(agtype_string, "vertices") do
%Path{vertices: [], edges: []}
else
%Vertex{id: nil, label: "Entity", properties: %{}}
end
end
def decode(_other), do: nil
end