Commit graph

361 commits

Author SHA1 Message Date
Zach Daniel
0007d0e60a fix: return proper data shape when doing a read in a transaction
closes #1410
2024-08-30 15:19:38 -04:00
Jinkyou Son
e2731ecd2d
Replace PaginationNotSupported exception with ActionRequiresPagination exception (#1411) 2024-08-30 13:11:46 -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
Zach Daniel
7cf38273fa improvement: prevent unnecessary calls to Ash.load 2024-08-20 11:55:46 -04:00
Zach Daniel
48507eac13 chore: run proper callback and test that we call the loading callback 2024-08-20 10:25:50 -04:00
Zach Daniel
51f57b6390 chore: pass context to load relationships 2024-08-20 10:18:01 -04:00
Jonatan Männchen
e200b5b9d1
chore: Implement upsert_condition for bulk create (#1389) 2024-08-14 20:26:03 -04:00
Zach Daniel
ba30ec880e chore: clean up tests 2024-08-14 11:46:18 -04:00
Zach Daniel
7cb3e04b2a fix: fix ets lateral join source field usage
fix: properly apply distinct in ets
2024-08-14 11:11:03 -04:00
Jonatan Männchen
93775109c7
improvement: Implement condition for upsert (#1386)
Resolves #1385
2024-08-13 19:19:13 -04:00
Zach Daniel
1654ccdead fix: properly pass actor, action, tenant etc. to lazy loaded relationships 2024-08-13 11:16:00 -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
54738baad2 fix: prefer source_attribute is required, instead of relationship name
we only do this if the source attribute is accepted by the action

fixes #1362
2024-08-02 09:41:34 -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
Riccardo Binetti
d199f701ac
fix: pass reuse_values? true when loading in Ash.Query.apply_to/2 (#1346)
The function is meant to be used to act on data that is in-memory, so it makes
sense to not read data again. Moreover this caused an infinite loop if using
this at the end of a manual read.
Add a regression test for the manual read case.
2024-07-25 07:21:08 -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
34d6f229c5 improvement: allow policy conditions to be applied inside their block
```elixir
policy do
  condition [...]
  authorize_if ...
end
```
2024-07-22 07:10:09 -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
Torkild Gundersen Kjevik
ad6954aca8
improvement: add strict? option to Ash.Query.load (#1302)
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-07-11 09:34:30 -04:00
Zach Daniel
e1dffc0c0c fix: properly enforce tenancy on all mutative actions 2024-07-06 13:41:58 -04:00
Hannes Wüthrich
0e5587552c
fix: invert logic for lazy-loading calculations/aggregates (#1275) 2024-07-03 07:06:11 -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
d53ad508cd test: update non-simple-equality manual relationship tests 2024-07-01 17:32:32 -04:00
kernel-io
3265b36589
fix: compare keys in manual relationships when using 'complex' types (#1270)
Signed-off-by: kernel-io <kernel-io@users.noreply.github.com>
2024-07-01 17:21:01 -04:00
Zach Daniel
66ebb1422e tests: more notification transaction tests 2024-06-28 13:59:03 -04:00
Zach Daniel
2d29dab90b fix: set tenant context when calling data layers
fix: set `from_many?` if a `has_one` has a `sort` applied

(because there is no other reason to apply a `sort`)
2024-06-28 11:13:34 -04:00
Zach Daniel
6898bde0a4 fix: proper return value from synthesized joins
fix: properly support multitenancy in joins in ets
2024-06-27 20:53:35 -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
Zach Daniel
9882037780 fix: set default argument values on generic actions
fixes #1220
2024-06-13 10:25:25 -04:00
Jechol Lee
c5d96e1a0a
chore: Fix warning: using map.field notation (#1238) 2024-06-13 08:02:35 -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
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
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