Ash FrameworkAF
Ash Framework7mo ago
104 replies
Ege

Sorting error: NoSuchField

Getting this error when trying to sort documents that have been uploaded by users:
(MatchError) no match of right hand side value: {:error, %Ash.Error.Invalid{errors: [%Ash.Error.Query.NoSuchField{resource: MyApp.Ash.Accounts.UserUpload, field: "uploaded_file_name", splode: Ash.Error, bread_crumbs: [], vars: [], path: [:sort], stacktrace: #Splode.Stacktrace<>, class: :invalid}]}}

Function that results in this error:
{:ok, %{results: documents, count: count}} =
  UserUpload.by_ids(
    %{organization_ids: org_ids},
    query: [sort_input: "meta.uploaded_file_name"],
    page: [limit: pagination.limit, offset: pagination.offset, count: true]
  )

UserUpload resource:
attributes do
  uuid_primary_key :id
  attribute :document, :string, public?: true
  attribute :meta, UserUploads.Meta, public?: true

  create_timestamp :inserted_at
  update_timestamp :updated_at
end

UserUploads.Meta resource:
attributes do
  attribute :uploaded_file_name, :string do
    public? true
  end
end
Was this page helpful?