Skip to content

Manual Relationship Should select all #2580

@allenwyma

Description

@allenwyma

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

Performing this action inside of a change for an update throws an error:

change fn changeset, _context ->
      Ash.Changeset.before_action(changeset, fn changeset ->
        case Ash.get(
               App.Services.Freshbooks.Service,
               Ash.Changeset.get_attribute(changeset, :freshbooks_id),
               load: [:rate],
               authorize?: false
             ) do
          {:error, _term} ->
            Ash.Changeset.add_error(changeset, "cannot get the service from Freshbooks")
...

error:

 * ** (UndefinedFunctionError) function Ash.Resource.ManualRelationship.Function.select/1 is undefined or private
       (ash 3.17.0) lib/ash/actions/read/read.ex:88: Ash.Actions.Read.run/3
       (ash 3.17.0) lib/ash.ex:2128: Ash.do_get/6
       (ash 3.17.0) lib/ash.ex:2103: Ash.get/3

Manual relationship:

has_one :rate, App.Services.Freshbooks.Service.Rate do
      no_attributes? true

      manual fn records, %{query: query} = _context ->
        Enum.map(records, fn %{id: id} ->
          query
          |> Ash.Query.filter(service_id == ^id)
          |> Ash.read_one!()
        end)
        |> Enum.reject(&is_nil/1)
        |> Enum.group_by(& &1.service_id)
        |> then(&{:ok, &1})
      end
    end

Detailed info: https://discord.com/channels/711271361523351632/1475051562823979082

Operating system

macos

Current Behavior

No response

Reproduction

No response

Expected Behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions