Commit graph

1412 commits

Author SHA1 Message Date
dependabot[bot]
c3190fe49c
chore(deps): bump ash_sql from 0.2.4 to 0.2.5 (#328) 2024-06-14 10:50:14 -04:00
dependabot[bot]
da4aae676e
chore(deps): bump ecto_sql from 3.11.2 to 3.11.3 (#327) 2024-06-14 10:50:02 -04:00
Jechol Lee
a3a2905c68
Fix Elixir 1.17 warnings (#326) 2024-06-13 19:54:22 -04:00
Zach Daniel
555ea28e21 chore: bump ash_sql version 2024-06-13 09:54:34 -04:00
Zach Daniel
1e29a239fd chore: release version v2.0.9 2024-06-13 09:54:16 -04:00
Zach Daniel
9cc942f233 chore: credo 2024-06-13 09:53:40 -04:00
Zach Daniel
c753a37cfe fix: fix invalid select on sorting by some calculations 2024-06-13 09:41:13 -04:00
Jefferson Queiroz Venerando
27837d1e30
test: Add a failing test for sorting on relationship (#324)
* add a failing test for sorting on relationship

* fix relationship pattern match

* fix title sort
2024-06-13 08:28:27 -04:00
dependabot[bot]
9531ffa0c4
chore(deps-dev): bump credo from 1.7.6 to 1.7.7 (#325)
Bumps [credo](https://github.com/rrrene/credo) from 1.7.6 to 1.7.7.
- [Release notes](https://github.com/rrrene/credo/releases)
- [Changelog](https://github.com/rrrene/credo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rrrene/credo/compare/v1.7.6...v1.7.7)

---
updated-dependencies:
- dependency-name: credo
  dependency-type: direct:development
  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-06-13 08:22:04 -04:00
dependabot[bot]
2bee2638a0
chore(deps): bump ash from 3.0.10 to 3.0.11 (#323)
Bumps [ash](https://github.com/ash-project/ash) from 3.0.10 to 3.0.11.
- [Changelog](https://github.com/ash-project/ash/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash/compare/v3.0.10...v3.0.11)

---
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-06-12 09:30:23 -04:00
Zach Daniel
b9e2fe45f4 test: add @moduletag :migration to squash snapshots test 2024-06-11 12:08:10 -04:00
Zach Daniel
85620a0f89 improvement: don't sort identity keys.
There are important implications here, specifically that there are
optimizations that can be had based on what the first column in a
unique constraint is, and we want to make sure that can be taken advantage of.

closes #313
2024-06-10 15:59:05 -04:00
Zach Daniel
49db2be6b2 fix: fix error message displaying in identity verifier
closes #320
2024-06-10 15:57:04 -04:00
Zach Daniel
8e32e0ab9a fix: ensure that context multitenancy is properly applied to lateral many-to-many joins 2024-06-10 12:49:04 -04:00
Zach Daniel
2c31b3e167 fix: don't assume old snapshots have index? key for attributes 2024-06-10 11:10:19 -04:00
Zach Daniel
f0779580b3 fix: list_tenants -> all_tenants
fix: when checking for roll back-able migrations, only check `Path.basename`
2024-06-10 09:09:10 -04:00
Robert Timis
6c81699b0d
feat: autogenerate index in references (#321)
* feat: autogenerate index in references

* check if old had index
2024-06-10 08:43:24 -04:00
dependabot[bot]
57b433023e
chore(deps): bump ash from 3.0.9 to 3.0.10 (#319)
Bumps [ash](https://github.com/ash-project/ash) from 3.0.9 to 3.0.10.
- [Changelog](https://github.com/ash-project/ash/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash/compare/v3.0.9...v3.0.10)

---
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-06-07 14:07:42 -04:00
Zach Daniel
a9aca443a0 chore: release version v2.0.8 2024-06-06 14:35:46 -04:00
Zach Daniel
4b5d980c69 chore: undo accidental git stash for previous commit 2024-06-06 14:34:01 -04:00
Zach Daniel
46452ba533 chore: update changelog 2024-06-06 13:10:59 -04:00
Zach Daniel
c8a2729864 chore: release version v2.0.7 2024-06-06 13:10:33 -04:00
Zach Daniel
72ec53599f fix: update ash_sql and fix issues retaining lateral join context 2024-06-06 13:10:05 -04:00
Jesse Williams
9940edf633
test: demonstrating issue filtering relationship by parent (#318) 2024-06-05 13:12:32 -04:00
dependabot[bot]
a68229af07
chore(deps-dev): bump benchee from 1.3.0 to 1.3.1 (#316)
Bumps [benchee](https://github.com/bencheeorg/benchee) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/bencheeorg/benchee/releases)
- [Changelog](https://github.com/bencheeorg/benchee/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bencheeorg/benchee/compare/1.3.0...1.3.1)

---
updated-dependencies:
- dependency-name: benchee
  dependency-type: direct:development
  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-06-05 08:20:58 -04:00
dependabot[bot]
74b0819e04
chore(deps): bump ash_sql from 0.2.1 to 0.2.2 (#317)
Bumps [ash_sql](https://github.com/ash-project/ash_sql) from 0.2.1 to 0.2.2.
- [Changelog](https://github.com/ash-project/ash_sql/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash_sql/compare/v0.2.1...v0.2.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-06-05 08:19:19 -04:00
Zach Daniel
df250964e0 fix: ensure that all current attribute values are selected on bulk update shifted root query
closes #314
2024-06-02 12:35:57 -04:00
Zach Daniel
cf9f6ec60a test: add test reproducing related aggregate reference 2024-06-02 12:35:57 -04:00
Mikael Muszynski
89da92bcd1
docs: Remove excess space in get-started-with-ash-postgres.md (#315) 2024-06-02 12:34:47 -04:00
Zach Daniel
bc46d9d9c4 test: add test reproducing related aggregate reference 2024-05-30 00:27:20 -05:00
Zach Daniel
93a536043c chore: release version v2.0.6 2024-05-29 12:33:20 -04:00
Zach Daniel
ff47ff0e06 fix: properly support aggregate references in atomic updates
(yes, you read that right)
2024-05-29 12:30:16 -04:00
dependabot[bot]
d3b2e96b7b
chore(deps): bump ash from 3.0.7 to 3.0.8 (#310) 2024-05-29 07:37:17 -04:00
Zach Daniel
9f1936aef4 fix: ensure that identities are dropped when where/nils_distinct? are changed
fix: ensure that `where` is wrapped in parenthesis
2024-05-28 13:52:53 -04:00
Zach Daniel
f8916c14ca improvement: require clarification of index names > 63 characters
closes #304
2024-05-28 13:32:20 -04:00
Zach Daniel
284928e5c1 chore: always reselect primary key on updates 2024-05-28 00:08:34 -04:00
Zach Daniel
4fbd821ee3 fix: support old/new parameterized type format
closes #308
2024-05-27 12:15:56 -04:00
Zach Daniel
33cfbd1cc4 chore: drop columns by default, change CLI option to dont-drop-columns
closes #307
2024-05-27 11:44:27 -04:00
Dmitry Maganov
06752d37e4
improvement: add ash_postgres.squash_snapshots mix task (#302) 2024-05-27 09:45:02 -04:00
Zach Daniel
633c00c2e9 chore: release version v2.0.5 2024-05-24 01:16:39 -04:00
Zach Daniel
8ad92cc3c0 improvement: update ash and support new identity features 2024-05-24 01:14:55 -04:00
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