Ash FrameworkAF
Ash Framework3y ago
2 replies
hassaan_ayyub

How to sort on a postgres regex?

I'm trying to extract a number from a text field using regex and sort on it.

require Ash.Query

def sort_on_regex(q) do
  q
  |> Ash.Query.sort([asc: expr(fragment( ... ))])
end

error: undefined function expr/1
error: undefined function fragment/1


Perhaps using calculations:

calculate :serial_no_int, :integer, expr( ... )


I can't figure out the syntax.

Thank you!
Was this page helpful?