A postgresql datalayer for the Ash Framework
Find a file
Alan Heywood acc947292d Add failing test for inserting via Ecto.Repo.insert!
It should be possible to use this function, and it did work as of ash
v2.5.9. This test fails as of ash v2.5.10, which introduced adding
relationships to underlying ecto schemas. The bug is related to a
has_many relationship being present on the resource.

The test fails with:

1) test call Ecto.Repo.insert! via Ash Repo (AshPostgres.EctoCompatibilityTest)
     test/ecto_compatibility_test.exs:6
     ** (Ecto.InvalidChangesetError) could not perform insert because changeset is invalid.

     Errors

         %{posts: [{"is invalid", [type: {:array, :map}]}]}

     Applied changes

         %{name: "The Org"}

     Params

         nil

     Changeset

         #Ecto.Changeset<
           action: :insert,
           changes: %{name: "The Org"},
           errors: [posts: {"is invalid", [type: {:array, :map}]}],
           data: #AshPostgres.Test.Organization<>,
           valid?: false
         >

     code: |> AshPostgres.TestRepo.insert!()
     stacktrace:
       (ecto 3.9.4) lib/ecto/repo/schema.ex:270: Ecto.Repo.Schema.insert!/4
       test/ecto_compatibility_test.exs:9: (test)
2023-01-30 10:40:45 +10:00
.github ci: update ash version in CI 2023-01-29 18:43:57 -05:00
.vscode improvement: support latest ash 2022-09-20 23:00:29 -04:00
config fix: use parent_expr instead of this 2023-01-06 17:05:23 -05:00
documentation docs: add a comment about config added earlier 2023-01-25 10:15:01 -05:00
lib fix: properly convert to/from ecto, only when necessary 2023-01-29 18:20:59 -05:00
logos feat: use the new DSL builder for config (#7) 2020-06-14 03:04:18 -04:00
priv Add failing test for policy + aggregate issue 2023-01-29 16:15:16 +10:00
test Add failing test for inserting via Ecto.Repo.insert! 2023-01-30 10:40:45 +10:00
test_snapshot_path improvement: fix typecasting for calculations & embed access 2022-08-05 15:27:22 -04:00
.check.exs improvement: update to the latest ash 2022-10-07 15:50:20 -04:00
.credo.exs improvement: support manual relationships with joins 2022-09-13 16:40:12 -04:00
.formatter.exs chore: format/lint 2022-11-21 03:08:04 -05:00
.gitignore feat: snapshot-based migration generator 2020-09-10 20:26:47 -04:00
CHANGELOG.md chore: release version v1.3.5 2023-01-29 18:24:19 -05:00
LICENSE Update LICENSE 2020-09-21 14:02:15 -04:00
mix.exs chore: release version v1.3.5 2023-01-29 18:24:19 -05:00
mix.lock chore: update ash to latest version 2023-01-29 18:42:40 -05:00
README.md chore: update readme 2022-10-17 16:45:06 -05:00

AshPostgres

Elixir CI License: MIT Coverage Status Hex version badge

AshPostgres supports all the capabilities of an Ash data layer. AshPostgres is the primary Ash data layer.

Custom Predicates:

  • AshPostgres.Predicates.Trigram

DSL

See the DSL documentation in AshPostgres.DataLayer for DSL documentation

Usage

Add ash_postgres to your mix.exs file.

{:ash_postgres, "~> 1.0"}

To use this data layer, you need to chage your Ecto Repo's from use Ecto.Repo, to use AshPostgres.Repo. because AshPostgres adds functionality to Ecto Repos.

Then, configure each of your Ash.Resource resources by adding use Ash.Resource, data_layer: AshPostgres.DataLayer like so:

defmodule MyApp.SomeResource do
  use Ash.Resource, data_layer: AshPostgres.DataLayer

  postgres do
    repo MyApp.Repo
    table "table_name"
  end

  attributes do
    # ... Attribute definitions
  end
end

Generating Migrations

See the documentation for Mix.Tasks.AshPostgres.GenerateMigrations for how to generate migrations from your resources

Contributors

Ash is made possible by its excellent community!

Become a contributor