Ash FrameworkAF
Ash Framework5mo ago
23 replies
rtorresware

Cannot find the right binding when sorting by fragment in many_to_many

    has_many :semantically_similar, __MODULE__ do
      no_attributes? true

      sort [
        calc(
          fragment(
            "? <=> ?",
            utterance.vectorized_content,
            parent(utterance.vectorized_content)
          )
        )
      ]

      limit 3
    end


it seems like this should be possible: https://hexdocs.pm/ash/expressions.html#many-to-many-relationships

The error:
(Ecto.SubQueryError) the following exception happened when compiling a subquery.\n\n (Ecto.QueryError) could not find named binding parent_as(1) in query"
Was this page helpful?