Compare commits
No commits in common. "v0.4.1" and "v0.4.0" have entirely different histories.
7 changed files with 14 additions and 89 deletions
|
@ -5,15 +5,6 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
||||||
|
|
||||||
<!-- changelog -->
|
<!-- changelog -->
|
||||||
|
|
||||||
## [v0.4.1](https://code.harton.nz/james/ash_cubdb/compare/v0.4.0...v0.4.1) (2023-10-02)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes:
|
|
||||||
|
|
||||||
* correctly enable filtering and sorting.
|
|
||||||
|
|
||||||
## [v0.4.0](https://code.harton.nz/james/ash_cubdb/compare/v0.3.1...v0.4.0) (2023-10-02)
|
## [v0.4.0](https://code.harton.nz/james/ash_cubdb/compare/v0.3.1...v0.4.0) (2023-10-02)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,14 @@ AshCubDb is still a work in progress. Feel free to give it a go.
|
||||||
| Read (by primary key) | ✅ |
|
| Read (by primary key) | ✅ |
|
||||||
| Read (filters) | ✅ |
|
| Read (filters) | ✅ |
|
||||||
| Read (sort) | ✅ |
|
| Read (sort) | ✅ |
|
||||||
| Read (distinct sort) | ✅ |
|
| Read (calculations) | ❌ |
|
||||||
| Read (calculations) | ✅ |
|
|
||||||
| Read (aggregates) | ❌ |
|
| Read (aggregates) | ❌ |
|
||||||
| Update | ✅ |
|
| Update | ✅ |
|
||||||
| Destroy | ✅ |
|
| Destroy | ✅ |
|
||||||
| Transactions | ❌ |
|
|
||||||
|
|
||||||
## Github Mirror
|
## Github Mirror
|
||||||
|
|
||||||
This repository is mirrored [on Github](https://github.com/jimsynz/ash_cubdb)
|
This repository is mirrored [on Github](https://github.com/jimsynz/smokestack)
|
||||||
from it's primary location [on my Forejo instance](https://code.harton.nz/james/ash_cubdb).
|
from it's primary location [on my Forejo instance](https://code.harton.nz/james/ash_cubdb).
|
||||||
Feel free to raise issues and open PRs on Github.
|
Feel free to raise issues and open PRs on Github.
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ by adding `ash_cubdb` to your list of dependencies in `mix.exs`:
|
||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:ash_cubdb, "~> 0.4.1"}
|
{:ash_cubdb, "~> 0.4.0"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
|
@ -57,15 +57,10 @@ defmodule AshCubDB.DataLayer do
|
||||||
def can?(resource, :read), do: Dir.readable?(resource)
|
def can?(resource, :read), do: Dir.readable?(resource)
|
||||||
def can?(_, :multitenancy), do: true
|
def can?(_, :multitenancy), do: true
|
||||||
def can?(_, :filter), do: true
|
def can?(_, :filter), do: true
|
||||||
def can?(_, :limit), do: true
|
|
||||||
def can?(_, :offset), do: true
|
|
||||||
def can?(_, :distinct), do: true
|
|
||||||
def can?(_, :distinct_sort), do: true
|
|
||||||
def can?(_, {:filter_expr, _}), do: true
|
def can?(_, {:filter_expr, _}), do: true
|
||||||
def can?(_, :boolean_filter), do: true
|
def can?(_, :boolean_filter), do: true
|
||||||
def can?(_, :sort), do: true
|
def can?(_, :sort), do: true
|
||||||
def can?(_, {:sort, _}), do: true
|
def can?(_, {:sort, _}), do: true
|
||||||
def can?(_, :nested_expressions), do: true
|
|
||||||
|
|
||||||
def can?(resource, capability) do
|
def can?(resource, capability) do
|
||||||
if Application.get_env(:ash_cubdb, :debug_data_layer_capabilities?, false) do
|
if Application.get_env(:ash_cubdb, :debug_data_layer_capabilities?, false) do
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -1,7 +1,7 @@
|
||||||
defmodule AshCubDB.MixProject do
|
defmodule AshCubDB.MixProject do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
@version "0.4.1"
|
@version "0.4.0"
|
||||||
|
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
A CubDB data layer for `Ash` resources.
|
A CubDB data layer for `Ash` resources.
|
||||||
|
@ -23,7 +23,7 @@ defmodule AshCubDB.MixProject do
|
||||||
aliases: aliases(),
|
aliases: aliases(),
|
||||||
dialyzer: [plt_add_apps: [:faker, :smokestack]],
|
dialyzer: [plt_add_apps: [:faker, :smokestack]],
|
||||||
docs: [
|
docs: [
|
||||||
main: "readme",
|
main: "AshCubDB",
|
||||||
extra_section: "Guides",
|
extra_section: "Guides",
|
||||||
formatters: ["html"],
|
formatters: ["html"],
|
||||||
filter_modules: ~r/^Elixir.AshCubDB/,
|
filter_modules: ~r/^Elixir.AshCubDB/,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
defmodule AshCubDB.DataLayerTest do
|
defmodule AshCubDB.DataLayerTest do
|
||||||
@moduledoc false
|
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
alias Ash.{Error.Query.NotFound, Query}
|
alias Ash.{Error.Query.NotFound, Query}
|
||||||
alias AshCubDB.Info
|
alias AshCubDB.Info
|
||||||
|
@ -141,51 +140,6 @@ defmodule AshCubDB.DataLayerTest do
|
||||||
|
|
||||||
assert Enum.map(sorted, &to_string(&1.name)) == ["Mallory", "Bob", "Alice"]
|
assert Enum.map(sorted, &to_string(&1.name)) == ["Mallory", "Bob", "Alice"]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "limit" do
|
|
||||||
insert!(Author, count: 3)
|
|
||||||
|
|
||||||
assert [_] =
|
|
||||||
Author
|
|
||||||
|> Query.limit(1)
|
|
||||||
|> Api.read!()
|
|
||||||
end
|
|
||||||
|
|
||||||
test "offset" do
|
|
||||||
insert(Author, count: 3)
|
|
||||||
|
|
||||||
assert [_, _] =
|
|
||||||
Author
|
|
||||||
|> Query.offset(1)
|
|
||||||
|> Api.read!()
|
|
||||||
end
|
|
||||||
|
|
||||||
test "distinct" do
|
|
||||||
author = insert!(Author)
|
|
||||||
insert!(Author, count: 3, attrs: %{name: author.name})
|
|
||||||
|
|
||||||
assert [selected] =
|
|
||||||
Author
|
|
||||||
|> Query.distinct(:name)
|
|
||||||
|> Api.read!()
|
|
||||||
|
|
||||||
assert selected.name == author.name
|
|
||||||
end
|
|
||||||
|
|
||||||
test "distinct sort" do
|
|
||||||
post = insert!(Post, attrs: %{body: "Alice is cool"})
|
|
||||||
insert!(Post, attrs: %{title: post.title, body: "Bob is cool"})
|
|
||||||
insert!(Post, attrs: %{title: post.title, body: "Mallory is cool"})
|
|
||||||
|
|
||||||
assert [selected] =
|
|
||||||
Post
|
|
||||||
|> Query.distinct(:title)
|
|
||||||
|> Query.distinct_sort(body: :desc)
|
|
||||||
|> Api.read!()
|
|
||||||
|
|
||||||
assert selected.title == post.title
|
|
||||||
assert selected.body == "Mallory is cool"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update" do
|
describe "update" do
|
||||||
|
@ -212,15 +166,6 @@ defmodule AshCubDB.DataLayerTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "calculations" do
|
|
||||||
test "can be loaded" do
|
|
||||||
post = insert!(Post)
|
|
||||||
{:ok, post} = Post.get(post.id, load: :all_text)
|
|
||||||
|
|
||||||
assert post.all_text == post.title <> post.body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp dump(resource) do
|
defp dump(resource) do
|
||||||
resource
|
resource
|
||||||
|> via()
|
|> via()
|
||||||
|
|
|
@ -7,28 +7,28 @@ defmodule Support.Author do
|
||||||
end
|
end
|
||||||
|
|
||||||
multitenancy do
|
multitenancy do
|
||||||
strategy :context
|
strategy(:context)
|
||||||
global? true
|
global?(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
attributes do
|
attributes do
|
||||||
uuid_primary_key :id
|
uuid_primary_key(:id)
|
||||||
|
|
||||||
attribute :name, :ci_string
|
attribute(:name, :ci_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
relationships do
|
relationships do
|
||||||
has_many :posts, Support.Post
|
has_many(:posts, Support.Post)
|
||||||
end
|
end
|
||||||
|
|
||||||
actions do
|
actions do
|
||||||
defaults ~w[create read]a
|
defaults(~w[create read]a)
|
||||||
end
|
end
|
||||||
|
|
||||||
code_interface do
|
code_interface do
|
||||||
define_for Support.Api
|
define_for(Support.Api)
|
||||||
|
|
||||||
define :create
|
define(:create)
|
||||||
define :read
|
define(:read)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,10 +19,6 @@ defmodule Support.Post do
|
||||||
defaults ~w[create read update destroy]a
|
defaults ~w[create read update destroy]a
|
||||||
end
|
end
|
||||||
|
|
||||||
calculations do
|
|
||||||
calculate :all_text, :string, expr(title <> body)
|
|
||||||
end
|
|
||||||
|
|
||||||
relationships do
|
relationships do
|
||||||
belongs_to :author, Support.Author
|
belongs_to :author, Support.Author
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue