Commit graph

784 commits

Author SHA1 Message Date
Jechol Lee
c5d96e1a0a
chore: Fix warning: using map.field notation (#1238) 2024-06-13 08:02:35 -04:00
Zach Daniel
00e294e050 fix: support ^arg/1 and similar constructions in filter policies on generic actions
closes #1221
2024-06-11 13:31:13 -04:00
Davide Briani
cd06f919c0
fix: load relationships on bulk operations (#1234)
This change validates that the `load` statement of bulk operations is
respected when specified, and correctly loads relationships.

Loading relationships with pagination on results for bulk destroys is
still not supported. Indeed, relationships are currently queried using a
lateral join but after the resource deletion has happened, so it looks
like nothing is related.

Signed-off-by: Davide Briani <davide@briani.dev>
2024-06-10 20:14:37 -04:00
Zach Daniel
d5d0b04bb6 improvement: validate require_attributes and allow_nil_input at compile time 2024-06-10 17:43:15 -04:00
Davide Briani
ae9671158f
fix: correctly load paginated relationships after create, update, delete (#1229)
Ensure that relationships can be correctly loaded, even with pagination,
on the resources resulting from create, update and delete actions.

Signed-off-by: Davide Briani <davide.briani@secomind.com>
2024-06-10 10:46:49 -04:00
Andreas Donig
4153ba7ef3
fix: fix the compare/2 implementations (#1232)
Co-authored-by: Andreas Donig <git@innwiese.de>
2024-06-10 08:15:51 -04:00
Robert Timis
6b964b9384
improvement: add tenant option to Ash.Seed.seed! (#1230) 2024-06-10 07:47:43 -04:00
Robert Timis
9c32eab87e
fix: fix seed not working when :__keep_nil__ is generated using seed_input (#1228) 2024-06-07 08:14:39 -04:00
Robert Timis
4d35117649
fix: add resource to Ash.Seed.seed! in Ash.Generator.seed! (#1227) 2024-06-07 07:31:29 -04:00
Zach Daniel
459426135e test: add example factory pattern for tests 2024-06-06 10:30:35 -04:00
Zach Daniel
e4980d55ba fix: don't update tenant on update, instead enforce it
the attribute strategy allowed for overwriting the multitenant attribute
on update. In practice, this can't really happen using any standard pattern
because any record to be updated is read with the tenant context, but it still
represents a small risk (and `schema` based multitenancy would enforce it in this
way anyway, so this is more consistent).
2024-06-05 10:43:38 -04:00
Zach Daniel
8799191165 test: add tests showing before_transaction hooks setting derived values 2024-06-02 11:59:18 -04:00
Zach Daniel
fbcafa1bfa fix: when hydrating nested aggregates, use correct related resource/path pair
closes #1213
2024-05-30 00:12:12 -05:00
Zach Daniel
1c21e390be fix: retain ref_path when authorizing aggregates 2024-05-29 14:03:33 -04:00
Zach Daniel
e9897eb50f fix: ensure that belongs_to relationships are properly not reloaded with lazy?: true
closes #1208
2024-05-29 12:59:10 -04:00
Jechol Lee
5dbf8fc0ed
fix get_domain (#1209) 2024-05-29 07:31:18 -04:00
Zach Daniel
bfdb8f9bab chore: format 2024-05-28 14:32:30 -04:00
Alan Heywood
2ee311b061
test: demonstrate error with bulk update on manual action (#1204)
The following error is produced

1) test manual updates are supported (Ash.Test.Actions.BulkUpdateTest)
     test/actions/bulk/bulk_update_test.exs:358
     ** (CaseClauseError) no case clause matching: nil
     code: |> Ash.bulk_update!(:update_manual, %{},
     stacktrace:
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:2076: anonymous fn/11 in Ash.Actions.Update.Bulk.run_batch/10
       (elixir 1.16.2) lib/enum.ex:1264: anonymous fn/3 in Enum.flat_map/2
       (stdlib 5.0.2) maps.erl:416: :maps.fold_1/4
       (elixir 1.16.2) lib/enum.ex:2540: Enum.flat_map/2
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:1966: Ash.Actions.Update.Bulk.run_batch/10
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:1505: Ash.Actions.Update.Bulk.do_handle_batch/13
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:1042: anonymous fn/12 in Ash.Actions.Update.Bulk.do_stream_batches/7
       (elixir 1.16.2) lib/stream.ex:613: anonymous fn/4 in Stream.map/2
       (elixir 1.16.2) lib/stream.ex:1816: anonymous fn/3 in Enumerable.Stream.reduce/3
       (elixir 1.16.2) lib/stream.ex:273: anonymous fn/4 in Stream.chunk_while_fun/2
       (elixir 1.16.2) lib/stream.ex:1159: anonymous fn/3 in Stream.with_index/2
       (elixir 1.16.2) lib/stream.ex:1079: Stream.do_transform_each/3
       (elixir 1.16.2) lib/stream.ex:1816: anonymous fn/3 in Enumerable.Stream.reduce/3
       (elixir 1.16.2) lib/enum.ex:4839: Enumerable.List.reduce/3
       (elixir 1.16.2) lib/stream.ex:1027: Stream.do_transform_inner_list/7
       (elixir 1.16.2) lib/stream.ex:1828: Enumerable.Stream.do_each/4
       (elixir 1.16.2) lib/stream.ex:1052: Stream.do_transform_inner_enum/7
       (elixir 1.16.2) lib/stream.ex:1828: Enumerable.Stream.do_each/4
       (elixir 1.16.2) lib/stream.ex:943: Stream.do_transform/5
       (elixir 1.16.2) lib/enum.ex:4396: Enum.reverse/1
       (elixir 1.16.2) lib/enum.ex:3728: Enum.to_list/1
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:1070: Ash.Actions.Update.Bulk.run_batches/3
       (ash 3.0.7) lib/ash/actions/update/bulk.ex:386: Ash.Actions.Update.Bulk.run/6
       (ash 3.0.7) lib/ash.ex:2209: Ash.bulk_update!/4
       test/actions/bulk/bulk_update_test.exs:373: (test)
2024-05-27 10:32:39 -04:00
Zach Daniel
adda85297c fix: multiple filter-checks in policy conditions were not composing properly 2024-05-24 22:58:05 -04:00
Zach Daniel
3057c4d936 chore: make credo happy 2024-05-24 21:57:54 -04:00
Zach Daniel
c45ecbfa49 fix: properly honor trailing policies that are constantly false 2024-05-24 21:03:06 -04:00
Zach Daniel
3510cd48f4 chore: clean up changelog and format 2024-05-24 00:35:13 -04:00
Zach Daniel
dc94f3a743 improvement: support nils_distinct? on identities
improvement: support `where` option on `identities`
improvement: allow calculations in identity keys

closes #1001
closes #1182
2024-05-24 00:24:42 -04:00
Zach Daniel
808692bbd7 fix: improve non-atomic-upgrade policy handling
fix: ensure we have a primary key for certain kinds of calculations:
2024-05-23 18:34:15 -04:00
Zach Daniel
e63d80e645 fix: handle subquery-requiring calculations in calculate/2 2024-05-23 17:33:29 -04:00
Zach Daniel
feb187bdf6 improvement: add atomic_upgrade? flag to update/destroy actions
improvement: do not do atomic upgrade by default unless `require_atomic?` is `true`
improvement: allow configuring the read action used by atomic upgrades
2024-05-23 11:05:17 -04:00
Zach Daniel
67c6e5e22a fix: ensure that all notifications are sent for bulk destroy/update
closes #1186
2024-05-22 18:42:19 -04:00
danielatdpg
05379e15b2
fix: handle list of atomic conditions (#1194) (#1195) 2024-05-22 11:38:15 -04:00
ab3786ebf6
feat(Ash.Reactor): Add bulk_update step type. (#1185) 2024-05-22 15:26:51 +12:00
Riccardo Binetti
86676cd0fc
feat: allow retrieving the count of paginated relationships (#1183) 2024-05-21 08:48:11 -04:00
Jinkyou Son
aae679f50e
improvement: Implement show_sensitive? config (#1180)
* Refactor with Ash.Helpers.redact/1

* Implement show_sensitive? config

* Use Application.compile_env/3 instead of Application.get_env/3

* Update sensitive-data.md
2024-05-21 08:47:51 -04:00
807ed72e89
chore: run formatter. 2024-05-21 09:17:58 +12:00
1d5d247d7a feat(Ash.Reactor): Add bulk_create step type. 2024-05-21 09:14:02 +12:00
Zach Daniel
a162b52b7f fix: use Ash.Sort.parse_input/3 in Ash.Query.sort_input/2 2024-05-20 09:52:52 -04:00
Riccardo Binetti
9fc5ddfe2b
fix: make Ash.Resource.Validation.Changing work correctly in atomics (#1178)
- Use the correct option key to select the field
- Fail without hitting the data layer if the attribute is not changing
- Allow checking relationships like the non-atomic counterpart
2024-05-16 18:15:35 -05:00
Riccardo Binetti
16b7ea7693
fix: check the where condition before checking validation atomicity (#1177)
:not_atomic was returned for a non-atomic validation even if the where condition
evaluated to false
2024-05-16 15:49:08 -05:00
Zach Daniel
23d7479417 fix: handle nil notification results better
fix: don't emit after batch notifications if `notify?: false`
2024-05-16 11:19:24 -05:00
Riccardo Binetti
65e9f51907
fix: don't require domain for empty stream bulk update and destroy (#1175)
It can't be extracted from an empty list, but it's not actually needed
2024-05-16 09:57:10 -05:00
Rebecca Le
619a0d61ad
bug: Add more failing tests around cascade_destroy functionality (#1173)
Issues occur when there is no data to cascade destroy, or notifications are requested but none are returned
2024-05-16 09:54:22 -05:00
Zach Daniel
7f7c1377cf fix: properly validate input action on bulk destroy
fix: allow setting `authorize?: false`
2024-05-16 00:02:18 -05:00
Rebecca Le
48b458c4fd
bug: Add failing test for verifying bulk destroy actions (#1172)
* bug: Add failing test for verifying bulk destroy actions

* bug: Add failing test for skipping authorization checks on a bulk destroy
2024-05-15 23:24:44 -05:00
Zach Daniel
7ec98ef8ab fix: properly persist simple_notifiers 2024-05-15 16:46:16 -04:00
Zach Daniel
5b18e71738 fix: accept ids in code interfaces again 2024-05-15 15:45:58 -04:00
Zach Daniel
ad0274b0a3 improvement: add pattern matching for clarity on ref/1 and ref/2
chore: remove debug logger configuration from test
2024-05-15 11:25:54 -04:00
Zach Daniel
2681684922 improvement: add can_return_nil?/1 callback to Ash expressions 2024-05-14 17:58:13 -04:00
Zach Daniel
3263ec2ee9 fix: don't show a type error on nil for lists
closes #1166
2024-05-14 17:09:34 -04:00
Davide Briani
449da541e2
Fix: keep data's metadata in atomic update (#1165) 2024-05-14 13:17:51 -04:00
Zach Daniel
23d78ec43f improvement: use the source configuration for attributes in embedded resources
closes #1143
2024-05-14 12:32:25 -04:00
12de8d19a5 fix(cascade_destroy): Always return and explicitly dispatch notifications.
**note** `notify?` option is now `return_notifications?`.
2024-05-13 09:28:20 +12:00
70c1a688f8 feat: Add cascade_destroy to builtin changes. 2024-05-13 09:28:20 +12:00