Andreas Donig
de0f72b475
Fix: honor bulk upsert condition ( #1432 )
...
* Require Ash.Expr to make sure upsert_conflict/1 is available
* Make sure it correctly tests opts[:upsert_condition] for nilness
* Make sure the base changeset also adheres to the upsert condition
* Revert the changes so we can show the problem with a test case
* Add a test case that shows what the problem is
* Add the upsert_condition filter to the base changeset again
* Change the way the test checks because bulk_create/4 does not return unchanged records
2024-09-03 16:23:12 -04:00
Zach Daniel
6f2a14715d
improvement: show an explanation when no policies apply
2024-09-02 12:48:36 -04:00
Zach Daniel
c7eaabdb2e
fix: correctly handle return values of batch callbacks ( #1424 )
...
* improvement: factor out static branches at compile time
---------
Co-authored-by: Hannes Wüthrich <hannes.wuethrich@zebbra.ch>
2024-08-31 15:53:14 -04:00
Zach Daniel
cb80df9ed8
test: test new default keyset pagination
2024-08-30 17:36:10 -04:00
Hannes Wüthrich
4a75743812
Fix generated change/3
function when only implementing batch_change/3
( #1415 )
2024-08-28 08:04:52 -04:00
Jonatan Männchen
e200b5b9d1
chore: Implement upsert_condition for bulk create ( #1389 )
2024-08-14 20:26:03 -04:00
Zach Daniel
a719c791ba
improvement: add optimized path for casting embeds when they are simple
...
improvement: add `include_embedded_source_by_default?` config to optimize embeds
improvement: support `:fields` constraint on `:struct` type, enabling persistence
2024-08-07 16:47:01 -04:00
Jonatan Männchen
d1efc3fb6c
fix: after_batch
arguments for bulk_create
with return_records?
disabled ( #1371 )
...
Fixes #1369
2024-08-07 16:17:40 -04:00
Jonatan Männchen
4efe51418e
improvement: Warn on bulk action return_stream?
without any other return_*?
options enabled. ( #1370 )
...
Resolves #1368
2024-08-07 14:51:15 -04:00
Zach Daniel
28f73546cc
fix: roll back bulk update/destroy on before action error
2024-08-01 12:09:01 -04:00
Zach Daniel
cb7b712460
improvement: implement change/3
automatically if batch callbacks are defined
...
fix: properly handle mixed atomic & non-atomic validations/changes
2024-07-29 19:54:12 -04:00
Barnabas Jovanovics
1ce0480a85
test: tests for atomic only validation ( #1331 )
2024-07-29 15:29:39 -04:00
Zach Daniel
dc4a63c86c
fix: ensure that statuses are set correctly on bulk actions
...
fix: properly transfer process context(tracers) for bulk actions
closes #1332
2024-07-26 11:38:41 -04:00
Zach Daniel
be542cf880
fix: only call batch_change
if it is defined, never change
in bulk create
2024-07-22 14:32:27 -04:00
Zach Daniel
6632f599bc
chore: keep only correct changes from earlier reverts
2024-07-17 15:08:19 -04:00
Zach Daniel
05cdaa04c5
Revert "fix: honor atomic validations in destroy actions using filter
"
...
This reverts commit a6a9961c0d
.
2024-07-17 15:06:39 -04:00
Zach Daniel
a6a9961c0d
fix: honor atomic validations in destroy actions using filter
...
test: add tests for atomic validations in destroy actions
2024-07-17 14:32:57 -04:00
Riccardo Binetti
3e39595730
test: add failing test for bulk update with numeric constraints ( #1310 )
2024-07-12 08:15:25 -04:00
Zach Daniel
d997902a6c
chore: raise explicit error on missing last_relationship/2
2024-07-02 15:19:33 -04:00
Zach Daniel
a3b026404e
test: add passing test for bulk update code interface policies
...
fix: properly match on async task exceptions
2024-07-02 14:33:13 -04:00
Zach Daniel
f13895b0f2
fix: override authorize?: nil
context
...
fix: ensure forbidden errors behave the same on `id` provided to code interfaces
2024-07-02 11:05:13 -04:00
Zach Daniel
b1d9c81725
chore: more list.wrapping of notifications
2024-07-02 10:41:15 -04:00
Zach Daniel
66ebb1422e
tests: more notification transaction tests
2024-06-28 13:59:03 -04:00
Ryan
a117327c0c
test: assert that notifications are sent for bulk updates and destroys using the :stream strategy ( #1266 )
2024-06-25 12:39:18 -04:00
Davide Briani
b256e1d8a3
test: Test loading paginated relationship when tenant is in primary key ( #1252 )
...
* Chore: test loading paginated relationship when tenant is in primary key
Ash is already able to load paginated relationships on multitenant
resources after a create or update action.
However this change specifically test the case of a many to many
relationship where the tenant is included in the primary key of the
joined resources.
Signed-off-by: Davide Briani <davide@briani.dev>
* fix: apply pagination at runtime for non lateral join queries
fix: consider multitenancy when checking if through-join is unique
---------
Signed-off-by: Davide Briani <davide@briani.dev>
Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-06-21 15:00:50 -04:00
Davide Briani
71d871b54a
Test loading relationships on multitenant resources after create or update ( #1249 )
...
* Chore: add tests on loading relationship on multitenant resource
Add tests to verify that relationships can be loaded on multitenant
resources after a create or update action.
Signed-off-by: Davide Briani <davide@briani.dev>
* fix: set tenant in ets data layer when generating aggregates
---------
Signed-off-by: Davide Briani <davide@briani.dev>
Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-06-20 16:46:29 -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
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
67c6e5e22a
fix: ensure that all notifications are sent for bulk destroy/update
...
closes #1186
2024-05-22 18:42:19 -04: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
11f0f9aa03
fix: ensure that changeset filters are honored in ETS destroy/update_query
...
fix: in simulated bulk actions, a stale record should be ignored
fix: don't rollback transactions on stale records
2024-05-12 16:16:39 -04:00
Riccardo Binetti
1f8c27225f
chore: add failing tests for filter on stream bulk update/destroy ( #1151 )
2024-05-12 15:32:13 -04:00
Zach Daniel
a26efe03e1
test: add test for requiring actor in atomic changes
2024-05-03 12:36:20 -04:00
Zach Daniel
6a1359c3d8
fix: various fixes around bulk actions, types, error handling
2024-05-02 23:48:10 -04:00
Zach Daniel
1bdc095b04
fix: fix match validation when performed atomically
2024-05-02 20:30:37 -04:00
Riccardo Binetti
a3418e32ef
fix: ensure only the intended failing test fails ( #1105 )
...
It was making also other tests fail
2024-05-02 19:15:26 -04:00
Riccardo Binetti
5ce12e35f8
chore: failing test for bulk update with global validations ( #1104 )
2024-05-02 17:18:08 -04:00
Zach Daniel
7fd063239f
fix: set notify?: true
when return_notifications?: true
is set
...
closes #1100
2024-05-02 14:51:35 -04:00
Zach Daniel
c1354d503e
fix: run changesets w/ after_transaction
hooks through standard logic
2024-05-02 00:06:31 -04:00
Zach Daniel
8a7a4763fd
chore: update bulk create test
2024-05-01 22:13:24 -04:00
Riccardo Binetti
bb22724ef9
chore: failing tests for after_transaction hooks on bulk failures ( #1090 )
2024-05-01 17:34:49 -04:00
Riccardo Binetti
b4821f2e13
chore: failing tests for before_transaction hooks in bulk actions ( #1081 )
2024-04-30 20:51:39 -04:00
Zach Daniel
3f977ff98d
improvement: simplifications and clarifications around bulk callback behavior
2024-04-27 10:14:31 -04:00
Zach Daniel
c8e93877ea
improvement: support atomics, update_query, destroy_query in ETS data layer
2024-04-25 22:18:54 -04:00
Zach Daniel
951eaba973
chore: fix build/test
2024-04-07 08:05:23 -04:00
Zach Daniel
d2ea5bb108
docs: rewrite action docs
...
improvement: synthesize attributes from atomics for better notifications
2024-04-07 08:02:10 -04:00