Commit graph

1421 commits

Author SHA1 Message Date
Zach Daniel
4e84a3f75d chore: release version v2.0.4 2024-05-23 18:42:16 -04:00
Zach Daniel
083807888c fix: ensure update's reselect all changing values
test: add calculation tests
2024-05-23 18:42:06 -04:00
Zach Daniel
e891c20b4f test: add tests for exists calculation 2024-05-23 18:41:43 -04:00
dependabot[bot]
cd9201af05
chore(deps): bump ash from 3.0.3 to 3.0.4 (#300)
Bumps [ash](https://github.com/ash-project/ash) from 3.0.3 to 3.0.4.
- [Changelog](https://github.com/ash-project/ash/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash/compare/3.0.3...v3.0.4)

---
updated-dependencies:
- dependency-name: ash
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-23 09:24:27 -04:00
Zach Daniel
249fa7a89a chore: release version v2.0.3 2024-05-22 17:49:49 -04:00
Zach Daniel
a372b6fd55 chore: update ash 2024-05-22 17:49:20 -04:00
Zach Daniel
264f4c0bac fix: handle complex maps/list on update
fix: support anonymous aggregates in sorts
fix: ensure parent_as bindings properly reference binding names

closes #296
closes #297
closes #298
2024-05-22 17:47:10 -04:00
Riccardo Binetti
a750abf8c4
chore: add tests for paginated relationship count (#294) 2024-05-20 22:42:56 -04:00
Alan Heywood
45d0284aa8
test: add failing test to demonstrate an error with nested aggregates (#295)
1) test complex aggregates (AshPostgres.Test.ComplexCalculationsTest)
     test/complex_calculations_test.exs:66
     ** (Ash.Error.Unknown) Unknown Error

     * ** (Ecto.SubQueryError) the following exception happened when compiling a subquery.

         ** (Ecto.SubQueryError) the following exception happened when compiling a subquery.

             ** (Ecto.QueryError) could not find named binding `parent_as(false)` in query:

             from c0 in AshPostgres.Test.ComplexCalculations.Certification,
               as: 0,
               left_lateral_join: s1 in subquery(from s0 in AshPostgres.Test.ComplexCalculations.Skill,
               as: 0,
               left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation,
               as: 0,
               where: parent_as(false).id == as(0).skill_id,
               where: type(
               as(0).status,
               {:parameterized, Ash.Type.Atom.EctoType,
                one_of: [:demonstrated, :performed, :approved, :reopened]}
             ) ==
               type(
                 ^"demonstrated",
                 {:parameterized, Ash.Type.Atom.EctoType,
                  one_of: [:demonstrated, :performed, :approved, :reopened]}
               ),
               group_by: [d0.skill_id],
               select: %{
               skill_id: map(d0, [:skill_id]).skill_id,
               count_of_demonstrated_documentations:
                 type(
                   coalesce(
                     count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})),
                     type(^0, {:parameterized, Ash.Type.Integer.EctoType, []})
                   ),
                   {:parameterized, Ash.Type.Integer.EctoType, []}
                 )
             }),
               on: true,
               where: parent_as(0).id == as(0).certification_id,
               where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) ==
               type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}),
               group_by: [s0.certification_id],
               select: %{
               certification_id: map(s0, [:certification_id]).certification_id,
               count_of_skills_ever_demonstrated:
                 type(
                   sum(
                     type(
                       fragment(
                         "(CASE WHEN ? THEN ? ELSE ? END)",
                         type(
                           coalesce(
                             as(1).count_of_demonstrated_documentations,
                             type(^0, {:parameterized, Ash.Type.Integer.EctoType, []})
                           ),
                           {:parameterized, Ash.Type.Integer.EctoType, []}
                         ) == type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}),
                         type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}),
                         type(^1, {:parameterized, Ash.Type.Integer.EctoType, []})
                       ),
                       {:parameterized, Ash.Type.Integer.EctoType, []}
                     )
                   ),
                   {:parameterized, Ash.Type.Integer.EctoType, []}
                 )
             }),
               on: true,
               where: type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []}) ==
               type(^"e24ef8a5-d39d-4293-9f69-1abd10a996e6", {:parameterized, Ash.Type.UUID.EctoType, []}),
               select: merge(
               merge(struct(c0, [:id]), %{
                 count_of_skills_ever_demonstrated:
                   type(
                     type(
                       s1.count_of_skills_ever_demonstrated,
                       {:parameterized, Ash.Type.Integer.EctoType, []}
                     ),
                     {:parameterized, Ash.Type.Integer.EctoType, []}
                   )
               }),
               %{}
             )

         The subquery originated from the following query:

         from s0 in AshPostgres.Test.ComplexCalculations.Skill,
           as: 0,
           left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation,
           as: 0,
           where: parent_as(false).id == as(0).skill_id,
           where: type(
           as(0).status,
           {:parameterized, Ash.Type.Atom.EctoType,
            one_of: [:demonstrated, :performed, :approved, :reopened]}
         ) ==
           type(
             ^"demonstrated",
             {:parameterized, Ash.Type.Atom.EctoType,
              one_of: [:demonstrated, :performed, :approved, :reopened]}
           ),
           group_by: [d0.skill_id],
           select: %{
           skill_id: map(d0, [:skill_id]).skill_id,
           count_of_demonstrated_documentations:
             type(
               coalesce(
                 count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})),
                 type(^0, {:parameterized, Ash.Type.Integer.EctoType, []})
               ),
               {:parameterized, Ash.Type.Integer.EctoType, []}
             )
         }),
           on: true,
           where: parent_as(0).id == as(0).certification_id,
           where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) ==
           type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}),
           group_by: [s0.certification_id],
           select: %{
           certification_id: map(s0, [:certification_id]).certification_id,
           count_of_skills_ever_demonstrated:
             type(
               sum(
                 type(
                   fragment(
                     "(CASE WHEN ? THEN ? ELSE ? END)",
                     type(
                       coalesce(
                         d1.count_of_demonstrated_documentations,
                         type(^..., {:parameterized, Ash.Type.Integer.EctoType, []})
                       ),
                       {:parameterized, Ash.Type.Integer.EctoType, []}
                     ) == type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}),
                     type(^..., {:parameterized, Ash.Type.Integer.EctoType, []}),
                     type(^..., {:parameterized, Ash.Type.Integer.EctoType, []})
                   ),
                   {:parameterized, Ash.Type.Integer.EctoType, []}
                 )
               ),
               {:parameterized, Ash.Type.Integer.EctoType, []}
             )
         }

     The subquery originated from the following query:

     from c0 in AshPostgres.Test.ComplexCalculations.Certification,
       as: 0,
       left_lateral_join: s1 in subquery(from s0 in AshPostgres.Test.ComplexCalculations.Skill,
       as: 0,
       left_lateral_join: d1 in subquery(from d0 in AshPostgres.Test.ComplexCalculations.Documentation,
       as: 0,
       where: parent_as(false).id == as(0).skill_id,
       where: type(
       as(0).status,
       {:parameterized, Ash.Type.Atom.EctoType,
        one_of: [:demonstrated, :performed, :approved, :reopened]}
     ) ==
       type(
         ^"demonstrated",
         {:parameterized, Ash.Type.Atom.EctoType,
          one_of: [:demonstrated, :performed, :approved, :reopened]}
       ),
       group_by: [d0.skill_id],
       select: %{
       skill_id: map(d0, [:skill_id]).skill_id,
       count_of_demonstrated_documentations:
         type(
           coalesce(
             count(type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []})),
             type(^0, {:parameterized, Ash.Type.Integer.EctoType, []})
           ),
           {:parameterized, Ash.Type.Integer.EctoType, []}
         )
     }),
       on: true,
       where: parent_as(0).id == as(0).certification_id,
       where: type(as(0).removed, {:parameterized, Ash.Type.Boolean.EctoType, []}) ==
       type(^false, {:parameterized, Ash.Type.Boolean.EctoType, []}),
       group_by: [s0.certification_id],
       select: %{
       certification_id: map(s0, [:certification_id]).certification_id,
       count_of_skills_ever_demonstrated:
         type(
           sum(
             type(
               fragment(
                 "(CASE WHEN ? THEN ? ELSE ? END)",
                 type(
                   coalesce(
                     as(1).count_of_demonstrated_documentations,
                     type(^0, {:parameterized, Ash.Type.Integer.EctoType, []})
                   ),
                   {:parameterized, Ash.Type.Integer.EctoType, []}
                 ) == type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}),
                 type(^0, {:parameterized, Ash.Type.Integer.EctoType, []}),
                 type(^1, {:parameterized, Ash.Type.Integer.EctoType, []})
               ),
               {:parameterized, Ash.Type.Integer.EctoType, []}
             )
           ),
           {:parameterized, Ash.Type.Integer.EctoType, []}
         )
     }),
       on: true,
       where: type(as(0).id, {:parameterized, Ash.Type.UUID.EctoType, []}) ==
       type(^"e24ef8a5-d39d-4293-9f69-1abd10a996e6", {:parameterized, Ash.Type.UUID.EctoType, []}),
       select: merge(
       merge(struct(c0, [:id]), %{
         count_of_skills_ever_demonstrated:
           type(
             type(
               s1.count_of_skills_ever_demonstrated,
               {:parameterized, Ash.Type.Integer.EctoType, []}
             ),
             {:parameterized, Ash.Type.Integer.EctoType, []}
           )
       }),
       %{}
     )

       (elixir 1.16.2) lib/enum.ex:1826: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
       (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
       (ecto 3.11.2) lib/ecto/repo/queryable.ex:214: Ecto.Repo.Queryable.execute/4
       (ecto 3.11.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
       (ash_postgres 2.0.2) lib/data_layer.ex:706: anonymous fn/3 in AshPostgres.DataLayer.run_query/2
       (ash_postgres 2.0.2) lib/data_layer.ex:704: AshPostgres.DataLayer.run_query/2
       (ash 3.0.2) lib/ash/actions/read/read.ex:2259: Ash.Actions.Read.run_query/4
       (ash 3.0.2) lib/ash/actions/read/read.ex:903: Ash.Actions.Read.reselect_and_load/5
       (ash 3.0.2) lib/ash/actions/read/read.ex:244: Ash.Actions.Read.do_run/3
       (ash 3.0.2) lib/ash/actions/read/read.ex:66: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.0.2) lib/ash/actions/read/read.ex:65: Ash.Actions.Read.run/3
       (ash 3.0.2) lib/ash.ex:1717: Ash.load/3
       (ash 3.0.2) lib/ash.ex:1687: Ash.load/3
       (ash 3.0.2) lib/ash.ex:1635: Ash.load!/3
       test/complex_calculations_test.exs:85: AshPostgres.Test.ComplexCalculationsTest."test complex aggregates"/1
       (ex_unit 1.16.2) lib/ex_unit/runner.ex:472: ExUnit.Runner.exec_test/2
       (stdlib 5.2) timer.erl:270: :timer.tc/2
       (ex_unit 1.16.2) lib/ex_unit/runner.ex:394: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4
     code: |> Ash.load!([:count_of_skills_ever_demonstrated])
     stacktrace:
       (elixir 1.16.2) lib/process.ex:860: Process.info/2
       (ash 3.0.2) lib/ash/error/unknown.ex:3: Ash.Error.Unknown."exception (overridable 2)"/1
       (ash 3.0.2) ash_postgres/deps/splode/lib/splode.ex:211: Ash.Error.to_class/2
       (ash 3.0.2) lib/ash/error/error.ex:66: Ash.Error.to_error_class/2
       (ash 3.0.2) lib/ash/actions/read/read.ex:324: Ash.Actions.Read.do_run/3
       (ash 3.0.2) lib/ash/actions/read/read.ex:66: anonymous fn/3 in Ash.Actions.Read.run/3
       (ash 3.0.2) lib/ash/actions/read/read.ex:65: Ash.Actions.Read.run/3
       (ash 3.0.2) lib/ash.ex:1717: Ash.load/3
       (ash 3.0.2) lib/ash.ex:1687: Ash.load/3
       (ash 3.0.2) lib/ash.ex:1635: Ash.load!/3
       test/complex_calculations_test.exs:85: (test)
2024-05-20 22:42:44 -04:00
Riccardo Binetti
0313734db0
chore: failing test for calculation ordered paginated relationship (#292) 2024-05-20 10:06:49 -04:00
dependabot[bot]
06f0f9befe
chore(deps): bump ecto_sql from 3.11.1 to 3.11.2 (#293)
Bumps [ecto_sql](https://github.com/elixir-ecto/ecto_sql) from 3.11.1 to 3.11.2.
- [Changelog](https://github.com/elixir-ecto/ecto_sql/blob/master/CHANGELOG.md)
- [Commits](https://github.com/elixir-ecto/ecto_sql/compare/v3.11.1...v3.11.2)

---
updated-dependencies:
- dependency-name: ecto_sql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-20 09:41:43 -04:00
Rebecca Le
eac2c722ea
docs: Clarify that references go inside a postgres block (#291) 2024-05-17 06:31:45 -05:00
Davide Briani
814e7de496
improvement: support on_delete: :nilify for specific columns (#289) 2024-05-16 19:18:17 -05:00
Riccardo Binetti
ad0b1a5c6c
chore: add relationship pagination tests (#265) 2024-05-16 17:28:43 -05:00
Riccardo Binetti
e29aa86870
chore: fix bulk destroy tests (#290)
* chore: fix bulk destroy tests

They were using an :update action

* chore: fix credo error
2024-05-16 15:48:38 -05:00
Zach Daniel
9b3e5d38fb test: update test to run authorization 2024-05-16 09:53:19 -05:00
Dmitry Maganov
74cead8749
test: add failing test for changing_attributes check for create (#288) 2024-05-16 08:39:47 -05:00
Zach Daniel
d5c55f6b10 fix: add and remove custom indexes in tandem properly 2024-05-16 00:14:38 -05:00
Zach Daniel
a3ee4814dc chore: release version v2.0.2 2024-05-15 16:53:32 -05:00
Zach Daniel
0d2f8f9916 chore: update ash 2024-05-15 16:52:03 -05:00
Zach Daniel
6153016080 chore: fix test for ^ref 2024-05-15 11:23:26 -04:00
Alan Heywood
3f00dcbe8e
test: add failing test to demonstrate error using ref (#282)
Filtering on ref in this manner worked up until Ash 3.0. Now, it gives
the following error:

1) test filter with ref (AshPostgres.FilterTest)
     test/filter_test.exs:1076
     ** (FunctionClauseError) no function clause matching in Ash.Filter.check_filterable/2

     The following arguments were given to Ash.Filter.check_filterable/2:

         # 1
         AshPostgres.Test.Organization

         # 2
         :id

     Attempted function clauses (showing 2 out of 2):

         defp check_filterable(_resource, [])
         defp check_filterable(resource, [relationship | rest])

     code: |> Ash.Query.filter(^ref(:id, [:posts, :comments]) == ^comment.id)
     stacktrace:
       (ash 3.0.1) lib/ash/filter/filter.ex:2944: Ash.Filter.check_filterable/2
       (ash 3.0.1) lib/ash/filter/filter.ex:2933: anonymous fn/2 in Ash.Filter.validate_filterable_relationship_paths/2
       (elixir 1.16.2) lib/enum.ex:4316: Enum.find_value_list/3
       (ash 3.0.1) lib/ash/filter/filter.ex:2923: Ash.Filter.validate_refs/3
       (ash 3.0.1) lib/ash/filter/filter.ex:3015: Ash.Filter.resolve_call/2
       (ash 3.0.1) lib/ash/filter/filter.ex:2489: Ash.Filter.add_expression_part/3
       (ash 3.0.1) lib/ash/filter/filter.ex:2427: anonymous fn/3 in Ash.Filter.parse_expression/2
       (elixir 1.16.2) lib/enum.ex:4839: Enumerable.List.reduce/3
       (elixir 1.16.2) lib/enum.ex:2582: Enum.reduce_while/3
       (ash 3.0.1) lib/ash/filter/filter.ex:334: Ash.Filter.parse/3
       (ash 3.0.1) lib/ash/query/query.ex:2574: Ash.Query.do_filter/3
       test/filter_test.exs:1095: (test)
2024-05-15 11:19:29 -04:00
Zach Daniel
6d825792b3 fix: rework the update and destroy query builder to support multiple kinds of joining 2024-05-15 11:15:34 -04:00
Barnabas Jovanovics
e597c39687
add test for rels in atomic updates (#286) 2024-05-15 09:50:36 -04:00
Sucipto
555a737493
fix: remove duplicate repo flags (#285) 2024-05-15 07:22:28 -04:00
dependabot[bot]
3371b6a313
chore(deps): bump ash from 3.0.0 to 3.0.1 (#281) 2024-05-14 14:13:21 -04:00
Zach Daniel
11852aec93 chore: update deps and add test 2024-05-14 12:36:16 -04:00
Barnabas Jovanovics
6d0cca1fae
test: show error with calc depending on other exists calc (#280) 2024-05-14 08:35:40 -04:00
Zach Daniel
4b6f2baddd docs: fix link to pg docs 2024-05-13 13:27:05 -04:00
dependabot[bot]
8a69af9a4b
chore(deps-dev): bump git_ops from 2.6.0 to 2.6.1 (#278) 2024-05-13 09:17:56 -04:00
Zach Daniel
d0c7984a89 test: add tests for action filters in bulk update/destroy
fix: ensure filter is included in stale record error message
2024-05-12 16:28:48 -04:00
Zach Daniel
11e8473a7c chore: release version v2.0.1 2024-05-12 12:51:13 -04:00
Zach Daniel
2421e6fc2c fix: properly parse previous version from migration generation 2024-05-12 12:51:13 -04:00
Nicholas Moen
9e2c01693f
docs: change 'Get Started' guide for Ash 3.0 compatibility (#277) 2024-05-11 22:20:52 -04:00
dependabot[bot]
66b2cfd0c7
chore(deps): bump ash_sql from 0.1.1-rc.19 to 0.1.2 (#276)
Bumps [ash_sql](https://github.com/ash-project/ash_sql) from 0.1.1-rc.19 to 0.1.2.
- [Changelog](https://github.com/ash-project/ash_sql/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash_sql/compare/v0.1.1-rc.19...v0.1.2)

---
updated-dependencies:
- dependency-name: ash_sql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-11 02:06:05 -04:00
dependabot[bot]
58f09e41c5
chore(deps-dev): bump credo from 1.7.5 to 1.7.6 (#275) 2024-05-11 02:02:51 -04:00
Zach Daniel
df53ef8613 chore: release version v2.0.0 2024-05-10 17:20:42 -04:00
Zach Daniel
590fb64db3 fix: ensure that codegen dry run works 2024-05-09 14:31:54 -04:00
Zach Daniel
8ce969317f docs: add additional context for nothing & restrict 2024-05-08 20:30:37 -04:00
Zach Daniel
4e64c6e70a docs: revamp changelog 2024-05-08 18:45:00 -04:00
dependabot[bot]
1cd808244b
chore(deps): bump ash from 3.0.0-rc.45 to 3.0.0-rc.46 (#272) 2024-05-07 12:02:06 -04:00
Zach Daniel
f6b1aa3d29 fix: ensure we don't duplicate selects on destroy_query calls
we fixed this by combining the logic for query building for bulk destroys
and bulk updates
2024-05-06 11:27:13 -04:00
Jechol Lee
459d853d28
fix: resolve_renames that keeps columns to be renamed in list of columns to add (#269) 2024-05-06 09:02:34 -04:00
dependabot[bot]
ca141cd095
chore(deps): bump ash_sql from 0.1.1-rc.18 to 0.1.1-rc.19 (#268)
Bumps [ash_sql](https://github.com/ash-project/ash_sql) from 0.1.1-rc.18 to 0.1.1-rc.19.
- [Changelog](https://github.com/ash-project/ash_sql/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash_sql/compare/v0.1.1-rc.18...v0.1.1-rc.19)

---
updated-dependencies:
- dependency-name: ash_sql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-06 09:01:58 -04:00
Rebecca Le
35fb3c7ea7
docs: Fix typo in page title (#267) 2024-05-06 09:01:31 -04:00
Zach Daniel
fa7de43532 chore: release version v2.0.0-rc.15 2024-05-05 11:40:31 -04:00
Zach Daniel
3334999eb1 fix: properly pass old version in when migrating extensions 2024-05-05 11:40:07 -04:00
Zach Daniel
4dd588c043 fix: honor dry_run option in extension migrations 2024-05-05 11:13:30 -04:00
Frank Dugan III
bc02a4d23c
feat: add timestamptz types (#266) 2024-05-05 06:08:21 -04:00
Zach Daniel
6cd11def01 chore: update ash_sql 2024-05-05 06:00:22 -04:00