fix: ensure calculation compiled

This commit is contained in:
Zach Daniel 2021-07-21 00:07:35 -04:00
parent 247abbb833
commit 0b8b704e2c
3 changed files with 1 additions and 9 deletions

View file

@ -76,6 +76,7 @@ defmodule Ash.Actions.Sort do
calc = Ash.Resource.Info.calculation(resource, field) ->
{module, opts} = calc.calculation
Code.ensure_compiled(module)
if :erlang.function_exported(module, :expression, 2) do
if Ash.DataLayer.data_layer_can?(resource, :expression_calculation_sort) do

View file

@ -2,12 +2,6 @@ defmodule Ash.Resource.Calculation.Expression do
@moduledoc false
use Ash.Calculation, type: :string
@doc false
# This exists to fix some very strange
# compile time errors, whereby Code.ensure_compiled(this_module)
# doesn't work, but calling a function on it does
def check, do: :ok
def expression(opts, context) do
expr =
Ash.Filter.build_filter_from_template(opts[:expr], nil, context, context[:context] || %{})

View file

@ -10,9 +10,6 @@ defmodule Ash.Sort do
alias Ash.Error.Query.{InvalidSortOrder, NoSuchAttribute}
# See the comment in that module for more on why this is here
Ash.Resource.Calculation.Expression.check()
@doc """
A utility for parsing sorts provided from external input. Only allows sorting
on public attributes and aggregates.