Ash FrameworkAF
Ash Framework4mo ago
27 replies
⿻ eileen

Invalid Filter Reference

I'm getting an Ash.Error.Query.InvalidFilterReference

I'm trying to push a particular filter into the DB level. I have this calculation, which works:

#issue.ex
    calculate :has_sitewide_approved_match?,
              :boolean,
              expr(
                exists(
                  scan.page.site.approved_issues,
                  rule_id == parent(rule_id) and
                    target == parent(target)
                )
              )


But when I try to use this in a filter expr(...) on its parent relationship (a scan has many issues), I get an invalid filter reference error:

#scan.ex
    has_many :unapproved_node_issues, NodeIssue do
      public? true
      filter expr(has_sitewide_approved_match? != true)
    end


The specific error is:

  * ** (MatchError) no match of right hand side value: {:error, [%Ash.Error.Query.InvalidFilterReference{field: :target, simple_equality?: nil, splode: Ash.Error, bread_crumbs: [], vars: [], path: [:filter], stacktrace: #Splode.Stacktrace<>, class: :invalid}]}


:target is just a simple string attribute.
Is it not possible to do what I'm trying to do?
Halp?
Was this page helpful?