Commit graph

3012 commits

Author SHA1 Message Date
pinetops
dd44d5dcf2
improvement: Add a case for handling mapsets in Filter.map (#1427) 2024-09-02 12:41:57 -04:00
pinetops
2c754f90a6
improvement: Cache always selected fields and use mapsets for building select list (#1428)
* Add attribute_names function on Info that returns MapSet

And use that when calculating select lists.
2024-09-01 17:06:51 -04:00
pinetops
cdbb0c4608
Normalize approach to caching attributes/calculations/relationships (#1425) 2024-09-01 12:44:45 -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
8ba9eeb3b4 fix: properly clean calculation dependency values, and don't unload them with lazy? 2024-08-31 15:32:54 -04:00
Zach Daniel
926762cf38 improvement: do not eager evaluate filters for read action policies 2024-08-31 14:34:29 -04:00
Zach Daniel
4adddcdd69 Revert "improvement: make authorization failures behave consistently across reads"
This reverts commit ffa37d0c95.
2024-08-30 19:51:46 -04:00
Zach Daniel
ffa37d0c95 improvement: make authorization failures behave consistently across reads 2024-08-30 19:45:28 -04:00
Zach Daniel
ec250ab7a4 fix: ensure that async limiter is cleared up front 2024-08-30 18:25:15 -04:00
Zach Daniel
bb07fa19a9 fix: ensure that update_defaults are set on streaming updates
fixes #1418
2024-08-30 18:12:30 -04:00
Zach Daniel
13a7c87daa fix: honor skip_global_validations? in bulk actions 2024-08-30 17:44:00 -04:00
Zach Daniel
cb80df9ed8 test: test new default keyset pagination 2024-08-30 17:36:10 -04:00
Zach Daniel
f4dc9620ae improvement: make default page type configurable, defaulting to :offset
The getting started guide and ash installer set it to `:keyset`

closes #1413
2024-08-30 17:18:50 -04:00
Zach Daniel
9b0fb15ecb fix: honor the countable option in pagination
the default unfortunately had to be changed to `true`, given that it was being ignored before

chore: clean up error declarations
2024-08-30 15:34:40 -04:00
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
pinetops
3859571fae
Improve caching of relationships and add caching of calculations (#1417)
Note that this likely demonstrates some broken code elsewhere,
demonstrated by the need to accept other types other than string and atoms.
2024-08-30 14:59:35 -04:00
Jinkyou Son
e2731ecd2d
Replace PaginationNotSupported exception with ActionRequiresPagination exception (#1411) 2024-08-30 13:11:46 -04:00
Zach Daniel
c7b861c511 fix: ensure that from is properly set on all notifications
fix: typo in bulk destroy not clearing ash_started_transaction state
2024-08-30 11:46:33 -04:00
pinetops
f63e86f9d6
improvement: add pattern for Ash.Query.Call in Filter.map (#1416) 2024-08-28 14:55:55 -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
55f1ead24f fix: do not add relationship filter when building relationship authorization 2024-08-26 11:49:00 -04:00
Zach Daniel
04382cbc53 fix: don't list telemetry handlers if app is compiling 2024-08-26 10:01:39 -04:00
Zach Daniel
dbe825b504 fix: handle no_attributes when joining lateral join relationship data 2024-08-23 11:27:03 -04:00
Andreas Donig
986d6e6467
docs: Fix an error in the changeset action lifecycle example (#1402) 2024-08-22 09:15:22 -04:00
Zach Daniel
05feea14ef chore: avoid emitting read spans when only loading data 2024-08-21 20:47:37 -04:00
Dmitry Maganov
8d4a4b055a
fix: do not call tracer set_metadata with span type that it ignores (#1400) 2024-08-21 19:43:40 -04:00
Zach Daniel
1f3059b5bf fix: traverse calculated relationships when rewriting transient calculation values
chore: clean up sort call to `function_exported?`
2024-08-21 19:34:19 -04:00
Zach Daniel
b841eaf54c chore: add tests for accept & some opts improvements 2024-08-21 11:58:11 -04:00
Zach Daniel
d593e3cee9 improvement: error at compile for bypasses that will have no effect
chore: remove unused `checks` field from `%Ash.Policy.Authorizer.Policy{}`
2024-08-20 21:30:55 -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
Zach Daniel
79c456f9fd chore: properly detect presense of load relationships 2024-08-20 09:39:48 -04:00
Zach Daniel
705e6b56e2 improvement: add load_relationships/5 callback to manual reads 2024-08-20 09:25:21 -04:00
Zach Daniel
f78d3ea7e5 chore: add final clause for uuid cast input 2024-08-19 22:05:30 -04:00
Zach Daniel
5fc5d32508 improvement: cache action known inputs individually
improvement: cache action required inputs all together
2024-08-19 21:49:34 -04:00
Zach Daniel
29e3a35d4c improvement: optimize to avoid inspects in changesets
improvement: optimize to avoid expensive `String.valid?` check in uuid type
2024-08-19 20:59:02 -04:00
Zach Daniel
d2d4be19fe improvement: add async? option to calculations, default to false
the vast majority of calculations will not benefit from being run
in a separate process, so the framework now defaults to running
them synchronously unless explicitly requested
2024-08-19 17:19:21 -04:00
Zach Daniel
a43624c9f3
improvement: add cascade update built in change (#1398)
---------

Co-authored-by: Alykhan Jetha <aj@marketcircle.com>
2024-08-19 11:34:38 -04:00
Zach Daniel
69b5e20b2f improvement: add uuid-v7-primary-key option to mix ash.gen.resource
closes #1396
2024-08-19 11:14:47 -04:00
Rebecca Le
057abfef18
docs: Stop the * in Ash.Type.* italicising everything when converted to Markdown (#1397) 2024-08-19 10:43:57 -04:00
Zach Daniel
7071884d05 improvement: optimize field checking for loading fields in query
improvement: allow functions in tracers for lazy loading metadata
2024-08-15 21:19:23 -04:00
Zach Daniel
5a6583a019 fix: optimize filter expr traversal 2024-08-15 19:37:42 -04:00
Zach Daniel
2e13d2b0df improvement: add read_action option to cascade_destroy 2024-08-15 10:49:36 -04:00
Zach Daniel
ce5c080492 improvement: don't start processes for single items in list
chore: add some benchmarks/flame files
2024-08-15 09:14:43 -04:00
Jonatan Männchen
e200b5b9d1
chore: Implement upsert_condition for bulk create (#1389) 2024-08-14 20:26:03 -04:00
Zach Daniel
87d8263abb improvement: support expr and expr_type options when building aggregates
for example:

```elixir
calculate(
  :max_comment_similarity,
  :float,
  expr(max(comments, expr_type: :float, expr: fragment("similarity(?, ?)", title, ^arg(:to))))
) do
  argument(:to, :string, allow_nil?: false)
end
```
2024-08-14 20:11:58 -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
545b7a60f2
improvement: Optimize option validation with compile time validators (#1387)
A user doing load testing of their Ash application is seeing *wildly* significant performance improvements from this change. Unexpected, but naturally very pleasing.
2024-08-13 19:04:58 -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
622561dc90 chore: add actor to policy errors for later use 2024-08-13 10:10:49 -04:00
Rebecca Le
074b65ed7d
chore: Report which module is at fault, when raising an error about relationship domain inclusion (#1384) 2024-08-12 08:47:18 -04:00
Zach Daniel
5b40040c76 chore: fix recent calculation optimization to never prune authorization calcs 2024-08-09 17:28:44 -04:00
Zach Daniel
7991d84b0b chore: don't enumerate empty list 2024-08-09 17:19:28 -04:00
Zach Daniel
dc73c3a3d5 feat: add policy groups
Policy groups allow you to group policies by shared conditions.
This can help simplify the mental overhead of large sets of policies.

For example:

```elixir
policies do
  policy_group actor_attribute_equals(:role, :owner) do
    policy action_type(:read) do
      authorize_if expr(owner_id == ^actor(:id))
    end

    policy action_type([:create, :update, :destroy]) do
      forbid_if
      authorize_if expr(owner_id == ^actor(:id))
    end
  end
end
```
2024-08-09 16:48:54 -04:00
Zach Daniel
5a4864650b improvement: prune calculations made unnecessary by field policies
closes #1356
2024-08-09 13:46:02 -04:00
Zach Daniel
dc3f921d33 fix: remove pattern match error when exceptions come from calculations 2024-08-09 10:07:54 -04:00
Zach Daniel
2f22905ff3 chore: add better errors to help debug strange path/field errors in sort code 2024-08-08 20:26:53 -04:00
Jinkyou Son
2fc934fb61
fix: Fix error with nil value on structure types (#1380)
* Fix no cond clause evaluated to a truthy value error

* Fix error with nil value

* Add tests
2024-08-08 20:15:20 -04:00
Zach Daniel
ea85829d98 improvement: add "hints" to NoSuchInput errors to make any errors clearer
closes #1352
2024-08-08 14:16:09 -04:00
Zach Daniel
e44d97bd25 fix: show proper error message when trying to accept non-writable attributes 2024-08-08 13:48:36 -04:00
Zach Daniel
793cd715a7 improvement: warn on usage of == nil 2024-08-08 13:05:39 -04:00
Zach Daniel
e4dcd1c397 improvement: implement Comp for atoms & strings, comparing atoms as strings 2024-08-08 11:38:16 -04:00
Zach Daniel
da91e2891e
fix: Pass options without :templated tuple to after_batch (#1376)
* Pass options without :templated tuple to after_batch

* fix: properly iterate non templated opts

---------

Co-authored-by: Jonatan Männchen <jonatan@maennchen.ch>
2024-08-08 10:14:06 -04:00
Zach Daniel
c0843b3eb7 chore: update igniter & fix warnings 2024-08-08 09:18:03 -04:00
Zach Daniel
a65a84fe83 chore: format 2024-08-08 09:07:59 -04:00
Jonatan Männchen
68ef4d3144
chore: Dialyzer Fixes (#1374) 2024-08-08 09:07:18 -04:00
Zach Daniel
b5d45325c5 chore: properly set atom keys & set error paths on embeddable types 2024-08-07 23:21:46 -04:00
Zach Daniel
4278660c9c chore: format 2024-08-07 23:02:05 -04:00
Zach Daniel
beb8ff7602 chore: fix error code in embeddable type 2024-08-07 22:57:31 -04:00
Zach Daniel
201687163f chore: update erorr message 2024-08-07 22:54:28 -04:00
Zach Daniel
823a9fbf4b chore: update error message 2024-08-07 22:53:10 -04:00
Zach Daniel
365ecffb5b improvement: increase cases where embedded attribute can be updated atomically 2024-08-07 22:45:38 -04:00
Zach Daniel
e86c5bce56 chore: follow up fixes for optimized embed creation 2024-08-07 22:16:19 -04:00
Zach Daniel
9a9e0c4e32 chore: properly set non-matched defaults in embeddable type 2024-08-07 21:36:37 -04:00
Zach Daniel
c8e1cddb2b fix: check for nil resource_calculation in Ash.Resource.loaded?/2 2024-08-07 21:35:42 -04:00
Zach Daniel
ac14b750d5 chore: add back in accidentally removed struct callbacks 2024-08-07 20:49:44 -04:00
Zach Daniel
1f056646a3 chore: set defaults in embedded attribute shortcut 2024-08-07 20:33:03 -04:00
Zach Daniel
ae2b737e87 fix: optimizations around allocating strings
fix: optimizations around list operations for embedded resources
2024-08-07 19:35:22 -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
Zach Daniel
1711ecf574 chore: split on specifically run_calculate/4 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
5684b5784a improvement: add stacktrace information 2024-08-06 21:38:08 -04:00
Zach Daniel
0576c8c602 fix: set upsert? option when managing relationships in bulk creation 2024-08-06 12:45:23 -04:00
Zach Daniel
40a832019e fix: resolve nested expression calculation references in runtime filters
fix: properly consider not-loaded record calculations as `:unknown`
2024-08-06 08:44:49 -04:00
Zach Daniel
960af4b887 fix: handle nil in atomic array casting 2024-08-06 07:11:56 -04:00
Zach Daniel
58065c31cd improvement: remove :comparable as a dependency
It all compiles conditionally, so that if an explicit dependency exists
on `comp` it will still be used
2024-08-05 16:04:47 -04:00
Zach Daniel
e94e484885 chore: remove IO.inspect 2024-08-05 12:37:28 -04:00
Zach Daniel
c4a910a5d1 improvement: support authorize_with option on Ash.read 2024-08-05 12:36:19 -04:00
Zach Daniel
85c92ce9cc chore: use nils_distinct? 2024-08-05 11:01:16 -04:00
Zach Daniel
3667760717 chore: format 2024-08-05 10:35:41 -04:00
m0rt3nlund
4508b439a5
improvement: Add defaults and typespec to resulting Resource struct (#1364)
* improvement: Add typespec to resource if it doesn't exist

---------

Co-authored-by: morten.lund@maskon.no <morten.lund@maskon.no>
Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-08-05 10:35:17 -04:00
Zach Daniel
4780376a8e fix: respect previously validated-for-action query for aggregates 2024-08-05 10:09:38 -04:00
Zach Daniel
e3e492ef65 fix: use timestamps() instead of timestamps 2024-08-02 12:49:26 -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
f8fc4cd521 fix: delete ash_notifications from pdict after reading 2024-08-01 10:42:19 -04:00
Zach Daniel
de7bd3576a docs: add typespec for build/2 2024-07-31 21:53:03 -04:00