Ash FrameworkAF
Ash Framework6mo ago
28 replies
Jarl André

Inconsistent behaviour between Ash.get and read actions, and Ash.load in context multitenancy (pg)

Ash.load(resource,[...], actor: user, tenant: company_id) works
Ash.get(resource, actor: user, tenant: company_id, load: [....]) doesnt work, same with custom read actions on resource
Is there some limitations with the context mulitenancy that i should be aware of? because i have struggled quite alot just loading relationships on resources, which should be one of the simplest things, but its not. I get wierd errors when i load with Ash.get or using custom read actions that there is not table like <UUID>.my_resource_table. It almost feels like it hits the wrong Repo or the wrong database. Im using two repos, but i just commented out the other repo from config and tried again, same error.
this is the error i get

%Ash.Error.Unknown{
  bread_crumbs: ["Error returned from: MyApp.Accounting.Resources.SupplierInvoice.by_id",
   "Error returned from: MyApp.Accounting.Resources.SupplierInvoiceLine.read"], 
  path: [:lines], 
  query: "#Query<>", 
  errors: [
    %Ash.Error.Unknown.UnknownError{
      error: "** (Postgrex.Error) ERROR 42P01 (undefined_table) relation \"49f7b9e2-c539-46c4-a518-8b556e6aa866.ash_supplier_invoice_lines\" does not exist",
      field: nil,
      value: nil,
      splode: Ash.Error,
      bread_crumbs: ["Error returned from: MyApp.Accounting.Resources.SupplierInvoice.by_id",
       "Error returned from: MyApp.Accounting.Resources.SupplierInvoiceLine.read"],
      vars: [],
      path: [:lines],
      stacktrace: #Splode.Stacktrace<>,
      class: :unknown
    }
  ]
}


any tips?
Solution
@Zach Daniel ill mark it as solved, i dont have time to debug why it failed in the old project. Its working in the new project now.
Was this page helpful?