Commit graph

2750 commits

Author SHA1 Message Date
Zach Daniel
30d73d5307 fix: ensure that calculation options are expanded 2024-06-26 14:18:27 -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
Matheus Cardoso
fc0ff54744
docs: Fix typo in Ash.Type constraint (#1264) 2024-06-25 09:21:50 -04:00
Zach Daniel
e4c3f825bb chore: only show values of errors from single known unions 2024-06-24 22:16:15 -04:00
Zach Daniel
c2a57c6e61 chore: don't use error_message on errors when casting single known union 2024-06-24 22:10:26 -04:00
Zach Daniel
14470bfd96 fix: properly return notifications on bulk code interface actions 2024-06-24 21:56:46 -04:00
Zach Daniel
6549fed3dd fix: properly send notifications for transaction: :all 2024-06-24 21:46:10 -04:00
Zach Daniel
dcfd53f22f chore: add back in and improve tmp_ref logic 2024-06-24 21:33:55 -04:00
Zach Daniel
daf4b08ab1 chore: more fixes for ash_started_transaction? 2024-06-24 19:55:38 -04:00
Zach Daniel
1d45802d32 fix: ensure we reset ash_started_transaction process flag 2024-06-24 19:51:20 -04:00
Zach Daniel
fb5e7e7e74 fix: ensure we always set ash_started_transaction? back to false 2024-06-24 19:47:24 -04:00
kernel-io
7ac9d9bdb2
fix: gather notifications in main ref not tmp ref. (#1263)
Signed-off-by: kernel-io <kernel-io@users.noreply.github.com>
2024-06-24 18:51:03 -04:00
Zach Daniel
83434b0d1a improvement: bulk destroy for handling array changes in embeds
improvement: set `__union_tag__` constraint in array handlers for unions
fix: sleep to avoid uuidv7 specifity flaky test
test: remove unused variable in tests
2024-06-24 09:48:08 -04:00
Zach Daniel
ec4ff55529 fix: ensure that we notify on code-interface id synthesized bulk operations 2024-06-24 08:38:45 -04:00
Zach Daniel
60630f23a6 fix: initialize subtypes of unions
fix: properly apply load-through behavior for arrays
2024-06-23 21:12:12 -04:00
Zach Daniel
eb5490fe6f improvement: support offset in the simple data layer
closes #1257
2024-06-23 20:22:21 -04:00
Zach Daniel
ced91af39f chore: avoid trying nil loads 2024-06-23 18:58:39 -04:00
Andreas Donig
23d504e151
Handle relationship filter on primary key (#1254)
Co-authored-by: Andreas Donig <git@innwiese.de>
2024-06-23 18:20:28 -04:00
Alessio Montagnani
7f2e7d3ec1
improvement: bring uuid version 7 into the core (#1253) 2024-06-23 18:16:20 -04:00
Zach Daniel
e17fa8a1c5 chore: get build passing 2024-06-23 17:44:02 -04:00
Zach Daniel
85b928b0d9 chore: remove IO.inspect 🤦🏻 2024-06-23 17:42:46 -04:00
Zach Daniel
9421dbe535 improvement: properly handle after_action hooks in fully atomic changesets 2024-06-23 17:41:11 -04:00
Zach Daniel
78114226a6 improvement: yes, we can in fact do after action hooks atomically 2024-06-23 16:30:10 -04:00
Zach Daniel
abb28cae4a improvement: make after_action change builtin atomic 2024-06-23 16:09:18 -04:00
Zach Daniel
04707aafd7 chore: elixir 1.17 warning 2024-06-21 19:41:08 -04:00
Zach Daniel
5727cc273f improvement: add mix ash.install
improvement: add `mix ash.gen.resource`
improvement: add `mix ash.gen.base_resource`
improvement: add `mix ash.gen.domain`
improvement: add `mix ash.extend`
2024-06-21 19:09:35 -04:00
Zach Daniel
af1fa5eca3 fix: use the proper opts when calling manual updates in bulk updates 2024-06-21 15:01:14 -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
Zach Daniel
2bdc6efde3 fix: don't run any before_action hooks if changeset is invalidated in prior hook 2024-06-21 11:04:26 -04:00
Zach Daniel
cb29738927 chore: fix credo/build 2024-06-20 18:43:51 -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
0eea01d21b chore: consider MapSet as valid for {:array type in matches_type?/2 2024-06-19 19:50:03 -04:00
Zach Daniel
62e06532f1 chore: fix typo in dirty hook checking 2024-06-19 11:29:22 -04:00
Zach Daniel
b32990df3a chore: support after_action hooks in atomic upgrade 2024-06-19 11:27:34 -04:00
Zach Daniel
97df7e714a fix: only prevent atomic upgrade when hooks were explicitly added 2024-06-19 11:23:52 -04:00
Dmitry Maganov
c0f1e2a622
fix: use right argument name in query set_result/clear_result (#1247) 2024-06-19 10:18:27 -04:00
Zach Daniel
2a2f20ade0 improvement: retain error context on overridden messages 2024-06-18 18:20:30 -04:00
Zach Daniel
29032725fb improvement: add optional matches_type?/2 callback to Ash.Type 2024-06-18 16:17:32 -04:00
Zach Daniel
91d4d86656 improvement: add backwards_compatible_interface? option to use Ash.Domain
use this to turn off inclusion of the old 2.0-based interface functions, i.e
`Domain.read`, `Domain.destroy`, `Domain.get` etc.
2024-06-18 11:56:32 -04:00
Zach Daniel
23973dc36e fix: apply join relationship filter when loading many_to_many relationships 2024-06-18 09:08:13 -04:00
Zach Daniel
154d43f6cc fix: ensure we honor any computed select changes when loading through attributes 2024-06-18 07:08:40 -04:00
Zach Daniel
54770a061f improvement: add subject and context keys to policy context 2024-06-17 22:01:00 -04:00
Zach Daniel
fa5d4a1a96 fix: don't start async limiter tasks if async is disabled
fix: properly set default timeout to `:infinity`

this avoids unnecessary processes starting when in the vast majority of cases some external thing is imposing a timeout.

fix: pass down `identity` when doing upserts, for new feature support
2024-06-17 10:56:48 -04:00
Zach Daniel
1fe799c7bb chore: fix match eror in changeset hook runner 2024-06-15 11:31:39 -04:00
Zach Daniel
2316b7b056 fix: ensure that before_transaction hook errors fail the operation
fix: ensure that `before_transaction` hook errors still trigger `after_transaction` hooks
2024-06-15 11:27:47 -04:00
Zach Daniel
f3943acdba fix: abort bulk updates on before transaction hook errors 2024-06-15 11:13:42 -04:00
Zach Daniel
05c51505f2 fix: fix expression interpolation for cast_atomic for integer, decimal, float 2024-06-14 14:16:20 -04:00
Barnabas Jovanovics
c3e02f7b9d
do not lose constraints context (#1242) 2024-06-14 10:48:19 -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
Zach Daniel
731fe30330 improvement: set a module when validating accepts 2024-06-12 09:37:24 -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
e3706c2552 improvement: use IO.warn for allow_nil_inputs error 2024-06-10 17:53:35 -04:00
Zach Daniel
d5d0b04bb6 improvement: validate require_attributes and allow_nil_input at compile time 2024-06-10 17:43:15 -04:00
Zach Daniel
22b5c644b8 chore: select -> query.select 2024-06-10 15:27:10 -04:00
Zach Daniel
5d4c51015e fix: only apply load through for attributes that are being selected directly
fix: ensure we lateral join with `from_many?: true` or any `:many` cardinality relationships
2024-06-10 15:23:26 -04:00
Zach Daniel
8dc0c2cb05 chore: remove ancient adapter code 2024-06-10 11:30:01 -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
46450f75e3 fix: return proper {:ok, value} from Ash.Type.Atom.apply_constraints/2 2024-06-10 10:43:14 -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
Zach Daniel
7f1849ca5c fix: return proper value from short-circuit filter hydration 2024-06-07 10:44:10 -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
17e34a2a27 fix: ensure that union types w/ explicit tags have constraints applied 2024-06-06 13:58:21 -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
51be60cb4b improvement: detect invalid resources placed in relationships on domains verifier 2024-06-05 09:48:32 -04:00
Andreas Donig
7d10c781d4
fix: Do not compare nil values in compare validation (#1223)
Co-authored-by: Andreas Donig <git@innwiese.de>
2024-06-05 09:23:33 -04:00
Zach Daniel
c9a7ac7ba9 improvement: warn at compile time on types that don't define atomic_update/2 2024-06-04 21:38:42 -04:00
Zach Daniel
3726f9b8b0 chore: List.wrap .load call on calculations 2024-06-03 19:30:10 -04:00
Zach Daniel
a3e3e8701f fix: ensure context is properly set on bulk manual action invocations
closes #1217
2024-06-02 11:44:15 -04:00
Riccardo Binetti
d71718c691
fix: use correct boolean operation names in Filter.find/4 (#1214) 2024-05-30 07:59:11 -05: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
4ab37a18f5 chore: fix 1.17 warning 2024-05-29 17:07:30 -04:00
Zach Daniel
2a304a581b fix: check if in transaction before trying to roll it back 2024-05-29 15:21:08 -04: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
Zach Daniel
49b69628f8 improvement: compatibility with elixir 1.17 2024-05-29 09:20:44 -04:00
Jechol Lee
99cc10a9c7
Ash.can? to be boolean | no_return (#1210) 2024-05-29 07:32:32 -04:00
Jechol Lee
5dbf8fc0ed
fix get_domain (#1209) 2024-05-29 07:31:18 -04:00
Zach Daniel
2d9ffe7fab fix: implement rollback on after hooks for bulk actions 2024-05-28 14:57:49 -04:00
Zach Daniel
bfdb8f9bab chore: format 2024-05-28 14:32:30 -04:00
Zach Daniel
4b873438dd fix: missing else caused manual updates not to work with bulk_update
closes #1205
2024-05-28 14:30:41 -04:00
Zach Daniel
6de8e765a9 improvement: verify notifiers all use the Ash.Notifier behaviour 2024-05-26 13:00:15 -04:00
Zach Daniel
b5dce2494a chore: optimize strict check fact checking 2024-05-24 23:07:46 -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
c45ecbfa49 fix: properly honor trailing policies that are constantly false 2024-05-24 21:03:06 -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
Joel Kociolek
d0ffc55924
fix: mixup between atomic upsert vs update capability of datalayers (#1198) 2024-05-23 12:19:20 -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
73a2ef4852 fix: only use Mix.deps_tree if defined
fixes #1197
2024-05-23 10:00:46 -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
Zach Daniel
9b3eace611 fix: properly hydrate and scope sorts
improvement: support anonymous aggregates and calculations in queries
2024-05-22 17:47:03 -04:00
danielatdpg
05379e15b2
fix: handle list of atomic conditions (#1194) (#1195) 2024-05-22 11:38:15 -04:00
Barnabas Jovanovics
3e7f691add
fix: handle nil value for old_values (#1191) 2024-05-22 09:01:35 -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