fix: attempt to fix calculation compile time issues

This commit is contained in:
Zach Daniel 2021-07-02 01:13:07 -04:00
parent fa192944e0
commit 382d39175b
2 changed files with 9 additions and 0 deletions

View file

@ -2,6 +2,12 @@ defmodule Ash.Resource.Calculation.Expression do
@moduledoc false @moduledoc false
use Ash.Calculation, type: :string 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 def expression(opts, context) do
expr = expr =
Ash.Filter.build_filter_from_template(opts[:expr], nil, context, context[:context] || %{}) Ash.Filter.build_filter_from_template(opts[:expr], nil, context, context[:context] || %{})

View file

@ -10,6 +10,9 @@ defmodule Ash.Sort do
alias Ash.Error.Query.{InvalidSortOrder, NoSuchAttribute} 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 """ @doc """
A utility for parsing sorts provided from external input. Only allows sorting A utility for parsing sorts provided from external input. Only allows sorting
on public attributes and aggregates. on public attributes and aggregates.