Thales Grilo
9d2da58fb2
improvement: Adds %Ash.NotSelected{} to ash 3 ( !634 ) ( #804 )
...
* ✨ create Ash.NotSelected, add test
* ✅ add ash_three test
* 👌 fix formatting
* 👌 add missing field value
---------
Co-authored-by: thales <thales@uplearn.co.uk>
2023-12-14 16:14:15 -05:00
Jechol Lee
728226bfee
test: Fix typo in MultitenancyTest ( #789 )
2023-12-01 13:02:06 -05:00
Darren Black
7106c61545
test: Failing test for Api.get ( #786 )
2023-11-29 20:05:36 -05:00
Barnabas Jovanovics
abb0854ae9
fix: remove destroyed or unrelated data from the relationship ( #767 )
2023-11-13 13:58:09 -05:00
Eduardo B. A
1775ab5a14
feat: Expand upsert_fields option ( #761 )
...
With this change, upsert_fields accepts the following options:
* `nil`: upsert fields not set;
* `:replace_all`: all fields from resource will be updated;
* `{:replace_all_except, [fields]}`: all fields from resource except fields inside `fields` will be updated;
* `{:replace, [fields]}`: only fields inside `fields` will be updated.
2023-11-13 13:23:16 -05:00
Frédérick Capovilla
76783b355b
feat: Add unknown argument error when passing an unknown key to an action. ( #750 )
...
* improvement: Add ash_three? feature flag for Ash 3.0 related behaviors.
* test: Add the ash_three test tag to exclude tests targetting Ash 3.0
2023-10-24 12:27:33 -04:00
Zach Daniel
2dbebf39e1
fix: properly determine resource from Ash.get!/2
2023-10-20 06:22:32 -04:00
Zach Daniel
ff88ce68b4
improvement: rewrite bulk creates, optimize changeset functions ( #744 )
2023-10-18 14:07:44 -04:00
Zach Daniel
d9bacc1554
fix: handle new type constraints properly
2023-10-17 12:50:14 -04:00
Zach Daniel
52337b7bff
improvement: various optimizations for bulk create actions
2023-10-16 23:50:05 -04:00
Zach Daniel
f53626e65d
improvement: support max_concurrency
option on bulk creates
...
improvement: better error message on missing identities
improvement: better error message on invalid data passed to `YourApi.load`
2023-10-16 14:53:27 -04:00
Zach Daniel
6e0be43c51
fix: properly authorize access to query aggregates in all cases
2023-10-11 19:44:50 -04:00
Zach Daniel
3782f1cfe2
fix: honor authorize?
option for calls to aggregate
2023-10-10 11:10:58 -04:00
Zach Daniel
fbe6b21bf0
improvement: support to-one reference paths in calculations
2023-10-09 18:50:15 -04:00
Zach Daniel
06d152c415
chore: remove IO.inspect
2023-10-07 17:08:12 -04:00
Zach Daniel
32620dfd52
improvement: add Ash.Sort.expr_sort
. In 3.0 sort should be a macro
2023-10-07 09:16:52 -04:00
Zach Daniel
04c9249f24
fix: properly perform field authorization on loaded through types
2023-09-28 10:23:16 -04:00
Barnabas Jovanovics
4fb6da6eee
test: update test to load forbidden field through union ( #713 )
2023-09-28 08:36:37 -04:00
Zach Daniel
2d9f9ee362
improvement: deprecate old school manual actions
...
note: these have been deprecated for a very long time, removing them will not
be considered a breaking change (and there will be clear compile errors)
2023-09-25 09:40:29 -04:00
Zach Daniel
b7b2f586a1
chore: format test
2023-09-22 17:05:07 -04:00
Zach Daniel
b13c7f0e53
improvement: add Ash.Query.around_transaction/2
2023-09-22 16:46:43 -04:00
Barnabas Jovanovics
b661022736
fix: sort operator names in keyset ( #684 )
2023-09-01 06:53:01 -04:00
Zach Daniel
c5ea541b2d
chore: rework atomics to atomic_update
change and function
...
improvement: add `Ash.context_to_opts/1-2`
2023-08-29 14:39:38 -04:00
Zach Daniel
18cb24e7f7
improvement: implement atomics, expression-based changes ( #682 )
...
there is still a lot of potential work that needs to be on this front.
1. supporting atomics on create actions.
2. supporting atomics in upserts (this one may actually be much easier than the first one, for postgres specifically, due to ecto implementation details)
3. discovering places atomics can be more nicely integrated into existing changes, validations, policies
2023-08-28 16:05:26 -04:00
Zach Daniel
7d5fd04e5c
fix: ensure that errors/records return the proper value in bulk creates
...
closes #681
2023-08-25 08:59:24 -04:00
Zach Daniel
cf99929230
improvement: initialize change opts in bulk actions
...
fix: better error message in `validate_related_resource_inclusion`
test: add test for arguments in bulk create actions
2023-08-02 12:41:54 -04:00
Zach Daniel
bda7c56543
improvement: support parent/1
in relationships
2023-07-26 16:46:22 -04:00
Zach Daniel
da73502a2f
fix: before/after batch callbacks are no longer broken
...
test: add tests for those callbacks being executed
2023-07-22 19:51:27 -04:00
Zach Daniel
1a9b2c8406
improvement: fix loading w/ only nil values
2023-06-22 10:37:25 -04:00
Zach Daniel
3f3a588df8
fix: properly handle lazy loaded many to many relationships
2023-06-14 19:52:05 -04:00
Zach Daniel
0e12686c61
fix: ensure attributes for keyset pagination are selected
2023-06-14 07:38:43 -04:00
Zach Daniel
d47dbe239c
improvement: properly pass calculation args in keyset filters
2023-06-11 20:48:42 -04:00
Zach Daniel
be57b909b5
fix: honor query limit when streaming
2023-06-10 13:09:45 -04:00
Zach Daniel
25acc2d793
improvement: better keyset pagination behavior on first and last pages
2023-06-09 15:08:49 -04:00
Zach Daniel
907aec5e82
improvement: support loading through types
...
Will document this in a separate PR. The broad strokes are this:
1. to load through an attribtue, `load(attribute: [:nested: :stuff])`
2. to load through a calculation, `load(calculation: {:%{...input}, nested: :stuff})`
3. union types support loading through them, and is done first by keying by the type name, i.e: `load(union: [type_name: [nested: :stuff])`.
4. union types support specifying a load statement for all types with `load(union: [*: [nested: :stuff]])`
2023-06-07 21:54:17 -04:00
Zach Daniel
8e7815388e
improvement: handle nil
s in memory the same way sql would have
2023-06-05 16:50:27 -04:00
Barnabas Jovanovics
1185b615f8
fix: Only create values for attributes that did not get a generator ( #595 )
2023-06-02 08:18:02 -04:00
Zach Daniel
5af9dc6696
fix: properly honor the return_errors?
option
2023-05-25 09:46:27 -04:00
Zach Daniel
f04ffd5ebd
improvement: support bulk upserts
2023-05-02 21:56:15 -04:00
Zach Daniel
523452cb94
docs: basic actions -> generic actions
2023-05-02 20:00:18 -04:00
Zach Daniel
1e61ae2d3c
improvement: finishing initial touches on bulk actions
2023-05-02 17:24:24 -04:00
Zach Daniel
0ced9c7639
fix: assorted bulk create fixes
2023-05-02 14:04:08 -04:00
Zach Daniel
80f696417d
improvement: bulk create actions
...
This is not currently supported by any data layer other than ETS
2023-05-02 13:19:00 -04:00
Zach Daniel
2843224f06
fix: handle invalid input in basic actions
2023-05-02 02:07:53 -04:00
Zach Daniel
49949ff58f
improvement: initial support for basic actions
2023-05-02 01:54:53 -04:00
Zach Daniel
fbc341b3a0
feat: add Api.stream!/1
2023-04-26 17:12:21 -04:00
Zach Daniel
38ec164e3e
improvement: include resource validations by default
...
improvement: validate explicit api configurations, with good error messages
2023-04-25 21:31:01 -06:00
Zach Daniel
ad347ca38b
improvement: rewrite calculation loader
...
Calculation loading is complex because different calculations can
depend on differently parameterized things. FOr example:
```elixir
def load(_, _, _), do: [foo: %{arg: 1}]
def load(_, _, _), do: [foo: %{arg: 2}]
```
The previous naive implementation would simply merge all of the calculation loads, which naturally would not work. Now we ensure that we load each requirement in isolation.
2023-03-28 20:34:15 -04:00
Zach Daniel
ed45a72ea6
improvement: add skip_global_validations?
option for actions
2023-03-21 13:33:48 -04:00
James Harton
171967d6de
improvement: Add get_by
option to read actions. ( #530 )
2023-03-21 18:03:06 +13:00
Zach Daniel
8b722e6460
fix: various fixes in aggregate authorization behavior
...
improvement: add `:read_action` and `:authorize?` configurations for resource aggregates
2023-03-17 12:02:37 -04:00
Zach Daniel
5c71e3b6bc
fix: properly handle allow_nil fields in keyset pagination
2023-02-27 12:18:18 -05:00
Zach Daniel
0c767d0fa1
chore: allow page: []
in new pagination error
2023-02-13 23:44:58 -05:00
Zach Daniel
9924cfc7c0
chore: fix page detection error
2023-02-13 23:38:02 -05:00
Kevin Mathew
0e6763d8cc
improvement: Add error message when page is added but pagination is not enabled ( #511 )
2023-02-13 23:20:40 -05:00
Zach Daniel
8ad1778763
fix: pagination behavior is incorrect
2023-02-09 21:21:58 -05:00
Zach Daniel
30eaf1c6e8
feat: initial (and slightly experimental) Api.aggregate support
2023-02-04 00:47:15 -05:00
Zach Daniel
a043e26116
fix: properly handle nested array type constraint validation
2023-02-03 10:32:05 -05:00
Zach Daniel
22e07c06b5
improvement: don't load dependencies for calcs in query
2023-01-17 01:46:33 -05:00
Maxim Martynov
7841075f35
improvement: Add Ash.Error.Invalid.TenantRequired error ( #471 )
2022-12-29 23:05:41 -05:00
Zach Daniel
55b3590f42
fix: more matching fixes on manual relationships
2022-12-07 01:10:34 -05:00
Zach Daniel
2f3fcbad13
improvement: optimize various solver boolean optimizations
...
improvement: more comprehensively remove unnecessary clauses
fix: resolve issue with `authorize_unless` and filter checks
improvement: prevent changing attributes and arguments after action validation
We allow for these changes inside of `before_action` calls, but otherwise
require that `force_change_attribute` is used, for example. This prevents
accidentally validating a changeset and then changing an attribute.
2022-11-23 03:39:00 -05:00
Zach Daniel
865f9aa253
improvement: return invalid primary key errors for Api.get
when the input can't be cast
2022-11-21 02:51:37 -05:00
Zach Daniel
a479970e23
improvement: much more readable errors when building loads
2022-11-21 01:37:58 -05:00
Zach Daniel
6994295a8f
fix: properly upsert all explicitly changed fields
...
fix: traverse maps for `template_references_actor?/1`
docs: various doc fixes
2022-10-31 11:33:51 -04:00
Zach Daniel
113d2452d2
improvement: replace templates in change/preparation/validation opts
...
Previously, only a few specific changes supported using `arg/1` or `context/1`
in their options. Now, those templates can be used in any change options,
built-in or not.
2022-10-31 02:25:01 -04:00
Zach Daniel
8cbd766172
feat: support anonymous functions in DSL
...
improvement: add more ergonomic manual action definitions.
The old method will likely be deprecated some time in the future (there is no rush really, they both work).
2022-10-30 21:00:57 -04:00
Zach Daniel
e52d7187d8
improvement: more additions to the resource builder, update spark
...
test: add a test for loading many to many relationships on code interface actions
2022-10-28 10:18:01 -05:00
Zach Daniel
235e965627
improvement: sort relationship in order of input when managing it
...
This helps with things like https://github.com/ash-project/ash_phoenix/issues/57
which involve rendering the relationship value after editing it. Retaining
the order allows direct reuse without any gymnastics
2022-10-19 00:39:10 -04:00
Zach Daniel
362180190c
fix: properly load calcs/aggs on manual relationships
...
It needs to be optimized, but it will do the trick for now.
2022-10-13 00:36:29 -04:00
Zach Daniel
48d96fc417
fix: properly load nested manual relationships
2022-10-12 21:30:48 -04:00
zimt28
fc4c60b125
improvement: Allow a single where
condition for validations ( #407 )
2022-10-07 11:24:04 -04:00
Zach Daniel
41b4b7fdbb
improvement: simplify async task strategy
...
We now only start tasks once the synchronous work is done as anything
synchronous should be fast, generally.
Additionally, if there is only one task that we are about to start,
we can be confident that all we're going to do is wait for it,
so we can simply run it synchronously
2022-10-06 01:54:44 -04:00
Zach Daniel
c24d8e6d21
Revert "fix: switch from no_depend_modules in most places"
...
This reverts commit 650d8920e4
.
2022-10-04 11:22:24 -04:00
Zach Daniel
650d8920e4
fix: switch from no_depend_modules in most places
2022-10-03 21:47:45 -04:00
Zach Daniel
1f6fb8d7af
chore: fix tests
2022-09-20 19:44:04 -04:00
Zach Daniel
87f20369bc
improvement: deprecate :replace
in favor of :relate_and_unrelate
2022-09-19 15:44:06 -04:00
Zach Daniel
2c2c207e68
fix: use Comp.equal?/2
when finding loaded data matches
2022-09-15 00:55:04 -04:00
Zach Daniel
e36f8c3e59
improvement: add filterable?
option to relationships
...
improvement: add data layer capability for aggregate relationships & filter relationships
improvement: add guide on manual relationships
2022-09-13 13:53:05 -04:00
Zach Daniel
dc154596f4
chore: add in commented test
2022-09-12 13:38:00 -04:00
Zach Daniel
f583ababbc
fix: fix keyset pagination ordering bug
...
fix: short names are snake cased
2022-09-12 11:17:44 -04:00
Zach Daniel
5c81d2b4a7
fix: properly do pagination
...
docs: fix some docs, add some guides
2022-09-11 22:19:37 -04:00
Zach Daniel
3644d05cd6
Revert "improvement: make two queries for full keyset pagination support"
...
This reverts commit 64b3312cb9
.
2022-09-11 18:35:02 -04:00
Zach Daniel
64b3312cb9
improvement: make two queries for full keyset pagination support
...
docs: add store context in process guide
2022-09-11 16:07:21 -04:00
Zach Daniel
c380cc1a14
docs: sanitize things for docs
2022-08-30 16:45:55 -06:00
Zach Daniel
04744f395f
improvement: move functions to more conventional places
...
improvement: move ash.formatter task to `spark.formatter`
2022-08-28 19:27:44 -06:00
Zach Daniel
6c79519b6c
improvement: make long-awaited DSL name changes
2022-08-28 19:27:44 -06:00
Zach Daniel
917131c21f
improvement: handle required but not accepted values better
2022-08-17 12:58:43 -04:00
Zach Daniel
c9f20f1488
improvement: add process-based actor, tenant and query/changeset context
...
improvement: add `always_authorize?` and `require_actor?` to api config
2022-07-19 00:49:05 -04:00
Zach Daniel
ba559936d8
improvement: code_interface optional arguments
...
test: add some load tests
2022-07-11 22:59:51 -04:00
Maciej Malecki
9707b4b7fe
Use a proper operator in the attribute_does_not_equal
validation ( #348 )
...
Previously, it was using `if current != expected do raise` while it
needs to do the opposite. Also, simplify the logic by making `update`
work in the same way as `create` (compare upcoming value - not the
original one).
2022-07-07 14:12:32 -04:00
Zach Daniel
394e2d089a
improvement: add match_other_defaults?
to attribute
2022-07-05 10:18:50 -04:00
Zach Daniel
ac4590a0ca
improvement: remove relationship writability, as it all happens through arguments now
...
improvement: repurpose `writable?` on `belongs_to` to make the attribute writable
2022-07-05 08:16:38 -04:00
Zach Daniel
f718ee94e7
improvement: new timeout error message and test it
2022-06-27 15:57:30 -04:00
Zach Daniel
ef3d1ea398
improvement: Ash.Generator
2022-06-21 21:00:47 -04:00
Zach Daniel
1d50c7aa79
improvement: add Ash.Seed
module with seed helpers
2022-06-20 17:01:28 -04:00
Zach Daniel
e19ca1ec66
fix: always return all notifications if return_notifications?: true
2022-06-09 13:52:32 -04:00
Zach Daniel
93424fd16a
fix: keyset pagination counts all rows
2022-05-31 11:56:15 -04:00
Zach Daniel
6d0cbec244
fix: fetch items closest to cursor by reversing keyset sort
2022-05-31 11:17:14 -04:00
Zach Daniel
669c98b379
fix: keyset + before results must be reversed
2022-05-31 10:34:35 -04:00