Skip to content

Commit 72cbc78

Browse files
committed
docs: clarify load option only works with Elixir calculations
1 parent a4741d8 commit 72cbc78

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

documentation/dsls/DSL-Ash.Resource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,7 @@ end
37523752
| [`description`](#calculations-calculate-description){: #calculations-calculate-description } | `String.t` | | An optional description for the calculation |
37533753
| [`public?`](#calculations-calculate-public?){: #calculations-calculate-public? } | `boolean` | `false` | Whether or not the calculation will appear in public interfaces. |
37543754
| [`sensitive?`](#calculations-calculate-sensitive?){: #calculations-calculate-sensitive? } | `boolean` | `false` | Whether or not references to the calculation will be considered sensitive. |
3755-
| [`load`](#calculations-calculate-load){: #calculations-calculate-load } | `any` | `[]` | A load statement to be applied if the calculation is used. |
3755+
| [`load`](#calculations-calculate-load){: #calculations-calculate-load } | `any` | `[]` | A load statement to be applied if the calculation is used. Only works with module-based or function-based calculations, not expression calculations. |
37563756
| [`allow_nil?`](#calculations-calculate-allow_nil?){: #calculations-calculate-allow_nil? } | `boolean` | `true` | Whether or not the calculation can return nil. |
37573757
| [`filterable?`](#calculations-calculate-filterable?){: #calculations-calculate-filterable? } | `boolean \| :simple_equality` | `true` | Whether or not the calculation should be usable in filters. |
37583758
| [`sortable?`](#calculations-calculate-sortable?){: #calculations-calculate-sortable? } | `boolean` | `true` | Whether or not the calculation can be referenced in sorts. |

documentation/topics/advanced/manual-installation.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,38 @@ config :spark, formatter: [remove_parens?: true]
2525
2626
```
2727

28-
Update `mix.exs`:
29-
```diff
30-
...
31-
defp deps do
32-
[
33-
+ {:sourceror, "~> 1.8", only: [:dev, :test]}
34-
# {:dep_from_hexpm, "~> 0.3.0"},
35-
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
36-
...
28+
Create `mix.exs`:
29+
```
30+
defmodule Elixir.Test.MixProject do
31+
use Mix.Project
32+
33+
def project do
34+
[
35+
app: :test,
36+
version: "0.1.0",
37+
elixir: "~> 1.17",
38+
start_permanent: Mix.env() == :prod,
39+
deps: deps()
40+
]
41+
end
42+
43+
# Run "mix help compile.app" to learn about applications.
44+
def application do
45+
[
46+
extra_applications: [:logger]
47+
]
48+
end
49+
50+
# Run "mix help deps" to learn about dependencies.
51+
defp deps do
52+
[
53+
{:sourceror, "~> 1.8", only: [:dev, :test]}
54+
# {:dep_from_hexpm, "~> 0.3.0"},
55+
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
56+
]
57+
end
58+
end
59+
3760
```
3861

3962
Update `.formatter.exs`:

lib/ash/resource/calculation/calculation.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ defmodule Ash.Resource.Calculation do
7272
load: [
7373
type: :any,
7474
default: [],
75-
doc: "A load statement to be applied if the calculation is used."
75+
doc: """
76+
A load statement to be applied if the calculation is used.
77+
Only works with module-based or function-based calculations, not expression calculations.
78+
"""
7679
],
7780
allow_nil?: [
7881
type: :boolean,
@@ -188,6 +191,10 @@ defmodule Ash.Resource.Calculation do
188191
@callback calculate(records :: [Ash.Resource.record()], opts :: opts, context :: Context.t()) ::
189192
{:ok, [term]} | [term] | {:error, term} | :unknown
190193
@callback expression(opts :: opts, context :: Context.t()) :: any
194+
@doc """
195+
A load statement to be applied when the calculation is used.
196+
Only works with module-based or function-based calculations, not expression calculations.
197+
"""
191198
@callback load(query :: Ash.Query.t(), opts :: opts, context :: Context.t()) ::
192199
atom | [atom] | Keyword.t()
193200
@callback strict_loads?() :: boolean()

0 commit comments

Comments
 (0)