Ash FrameworkAF
Ash Framework3mo ago
3 replies
Shahryar

Error to use `filter expr` with `manage_relationship` Unknown Error

Hi dear friends! i have a relation like this, as you see i added filter expr to prevent user not send request when they are not master user (without tenant and site_id)
    has_many :master_versions, MishkaDocument.WorkspaceVersion do
      public? true
      destination_attribute :workspace_id
      read_action :read_any
      description "All versions of this workspace (master admin access, bypass tenant)"
      filter expr(is_nil(type(^actor(:tenant_id), :uuid)))
    end


and inside my create i have this
change manage_relationship(:version_ids, :master_versions,
               type: :append_and_remove,
               on_no_match: :error,
               on_match: :ignore
             )

But i get this error
     ** (Ash.Error.Unknown)
     Bread Crumbs:
       > Exception raised in: MishkaDocument.WorkspaceVersion.read
       > Exception raised in: MishkaDocument.Workspace.master_create

     Unknown Error

     * ** (RuntimeError) Unsupported expression in Elixir.AshPostgres.SqlImplementation query: {:_actor, :tenant_id}

is there prevent user not to send request here not the relation resource policy?
By the way i bypassed it with another ways, but is there any way for it? when tenant dose not exist
Thank you
Was this page helpful?