Skip to content

Commit eb08fed

Browse files
committed
improvement: fixes for 3.0 changes and AshSql changes
1 parent efcc1a6 commit eb08fed

10 files changed

+43
-34
lines changed

lib/data_layer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ defmodule AshPostgres.DataLayer do
546546

547547
@impl true
548548
def set_context(resource, data_layer_query, context) do
549-
AshSql.Query.set_context(resource, data_layer_query, context)
549+
AshSql.Query.set_context(resource, data_layer_query, AshPostgres.SqlImplementation, context)
550550
end
551551

552552
@impl true

lib/migration_generator/migration_generator.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ defmodule AshPostgres.MigrationGenerator do
25202520
defp has_create_action?(resource) do
25212521
resource
25222522
|> Ash.Resource.Info.actions()
2523-
|> Enum.any?(&(&1.type == :create))
2523+
|> Enum.any?(&(&1.type == :create && !&1.manual))
25242524
end
25252525

25262526
defp check_constraints(resource) do

lib/sql_implementation.ex

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ defmodule AshPostgres.SqlImplementation do
44

55
require Ecto.Query
66

7+
@impl true
8+
def manual_relationship_function, do: :ash_postgres_join
9+
10+
@impl true
11+
def manual_relationship_subquery_function, do: :ash_postgres_subquery
12+
13+
@impl true
14+
def require_ash_functions_for_or_and_and?, do: true
15+
16+
@impl true
17+
def require_extension_for_citext, do: {true, "citext"}
18+
719
@impl true
820
def expr(
921
query,
@@ -136,11 +148,11 @@ defmodule AshPostgres.SqlImplementation do
136148
end
137149

138150
def parameterized_type(Ash.Type.CiString, constraints, no_maps?) do
139-
parameterized_type(Ash.Type.CiStringWrapper, constraints, no_maps?)
151+
parameterized_type(AshPostgres.Type.CiStringWrapper, constraints, no_maps?)
140152
end
141153

142-
def parameterized_type(Ash.Type.String.EctoType, constraints, no_maps?) do
143-
parameterized_type(Ash.Type.StringWrapper, constraints, no_maps?)
154+
def parameterized_type(Ash.Type.String, constraints, no_maps?) do
155+
parameterized_type(AshPostgres.Type.StringWrapper, constraints, no_maps?)
144156
end
145157

146158
def parameterized_type(:tsquery, constraints, no_maps?) do
@@ -167,13 +179,6 @@ defmodule AshPostgres.SqlImplementation do
167179
if cast_in_query? do
168180
type = Ash.Type.ecto_type(type)
169181

170-
type =
171-
if type.type(constraints) == :ci_string do
172-
Ash.Type.CiStringWrapper
173-
else
174-
type
175-
end
176-
177182
parameterized_type(type, constraints, no_maps?)
178183
else
179184
nil

lib/types/ci_string_wrapper.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Ash.Type.CiStringWrapper do
1+
defmodule AshPostgres.Type.CiStringWrapper do
22
@moduledoc false
33
use Ash.Type
44

lib/types/string_wrapper.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Ash.Type.StringWrapper do
1+
defmodule AshPostgres.Type.StringWrapper do
22
@moduledoc false
33
use Ash.Type
44

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ defmodule AshPostgres.MixProject do
154154
defp deps do
155155
[
156156
{:ash, ash_version("~> 3.0.0-rc.0")},
157-
{:ash_sql, "~> 0.1.1-rc.0"},
157+
{:ash_sql, "~> 0.1.1-rc.3"},
158158
{:ecto_sql, "~> 3.9"},
159159
{:ecto, "~> 3.9"},
160160
{:jason, "~> 1.0"},
@@ -178,7 +178,7 @@ defmodule AshPostgres.MixProject do
178178
default_version
179179

180180
"local" ->
181-
[path: "../ash"]
181+
[path: "../ash", override: true]
182182

183183
"main" ->
184184
[git: "https://github.com/ash-project/ash.git"]

mix.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
2-
"ash": {:hex, :ash, "3.0.0-rc.0", "5acbfff801258624320dad950b07ea20ac6d8fe06a197d96c806d0bc5567c1b1", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.8", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.7 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e0ff1ba71b7096480da0a1472b95de7b73b88971eeb78a20779ed2bbba532df8"},
3-
"ash_sql": {:hex, :ash_sql, "0.1.1-rc.0", "79c463fd59c864d39e96ec5a1cf9b509a8bb9b8a4c6a55a2a562bbc43159d2a8", [:mix], [{:ash, "~> 3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "014ebd36b8a56ddcd79f04958567abe173000bc4ca2ce169029d8b51d2c9267a"},
2+
"ash": {:hex, :ash, "3.0.0-rc.6", "78d9bc068a0c632e4fe2db8a8802f772c65329c8bc15877ceb6eb2ac83e1fa8b", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.8", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.7 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3e0ccc857572d10972868886aff46f9b1d11c90f8b357f85f2887e71f702e916"},
3+
"ash_sql": {:hex, :ash_sql, "0.1.1-rc.3", "4d0043b6560a90da70f9d1950968113b2fcb3e0e036a2e4112168ea3786c8429", [:mix], [{:ash, "~> 3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "b6f32c1d3ec86983481708583be9d6b0959adbc1cb2de8987c816eb238b97762"},
44
"benchee": {:hex, :benchee, "1.3.0", "f64e3b64ad3563fa9838146ddefb2d2f94cf5b473bdfd63f5ca4d0657bf96694", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "34f4294068c11b2bd2ebf2c59aac9c7da26ffa0068afdf3419f1b176e16c5f81"},
55
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
66
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
@@ -26,13 +26,13 @@
2626
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
2727
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
2828
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
29-
"postgrex": {:hex, :postgrex, "0.17.4", "5777781f80f53b7c431a001c8dad83ee167bcebcf3a793e3906efff680ab62b3", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "6458f7d5b70652bc81c3ea759f91736c16a31be000f306d3c64bcdfe9a18b3cc"},
29+
"postgrex": {:hex, :postgrex, "0.17.5", "0483d054938a8dc069b21bdd636bf56c487404c241ce6c319c1f43588246b281", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "50b8b11afbb2c4095a3ba675b4f055c416d0f3d7de6633a595fc131a828a67eb"},
3030
"reactor": {:hex, :reactor, "0.8.1", "1aec71d16083901277727c8162f6dd0f07e80f5ca98911b6ef4f2c95e6e62758", [:mix], [{:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ae3936d97a3e4a316744f70c77b85345b08b70da334024c26e6b5eb8ede1246b"},
3131
"simple_sat": {:hex, :simple_sat, "0.1.1", "68a5ebe6f6d5956bd806e4881c495692c14580a2f1a4420488985abd0fba2119", [:mix], [], "hexpm", "63571218f92ff029838df7645eb8f0c38df8ed60d2d14578412a8d142a94471e"},
3232
"sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"},
3333
"sourceror": {:hex, :sourceror, "1.0.2", "c5e86fdc14881f797749d1fe5df017ca66727a8146e7ee3e736605a3df78f3e6", [:mix], [], "hexpm", "832335e87d0913658f129d58b2a7dc0490ddd4487b02de6d85bca0169ec2bd79"},
34-
"spark": {:hex, :spark, "2.1.8", "406256443d5e23ec034a0520c5bee703385ce0840825194aa583c96c22c2a349", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "cc46f7b3d31efe7995d6348e1664b1e18d5193761ad5462d61059078578d5f4c"},
35-
"splode": {:hex, :splode, "0.2.0", "a1f3b5a8e7c957be495bf0f22dd9e0567a87ec63559963a0ce0c3f0e8dfacedc", [:mix], [], "hexpm", "7cfecc5913ff7feeb04f143e2494cfa7bc6d5bb5bec70f7ffac94c18ea97f303"},
34+
"spark": {:hex, :spark, "2.1.11", "8093149dfd583b5ce2c06e1fea1faaf4125b50e4703138b2cbefb78c8f4aa07f", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "1877d92ab993b860e9d828bfd72d50367c0d3a53dd84f4de5d221baf66ae8723"},
35+
"splode": {:hex, :splode, "0.2.1", "020079ec06c9e00f8b6586852e781b5e07aee6ba588f3f45dd993831c87b0511", [:mix], [], "hexpm", "d232a933666061fe1f659d9906042fa94b9b393bb1129a4fde6fa680033b2611"},
3636
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
3737
"stream_data": {:hex, :stream_data, "0.6.0", "e87a9a79d7ec23d10ff83eb025141ef4915eeb09d4491f79e52f2562b73e5f47", [:mix], [], "hexpm", "b92b5031b650ca480ced047578f1d57ea6dd563f5b57464ad274718c9c29501c"},
3838
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},

test/ash_postgres_test.exs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ defmodule AshPostgresTest do
2222
post
2323
|> Ash.Changeset.for_update(:update, %{title: "bad"},
2424
authorize?: true,
25+
actor: nil,
2526
actor: %{id: Ash.UUID.generate()}
2627
)
27-
|> Ash.update!()
28+
|> Ash.update!(
29+
authorize?: true,
30+
actor: nil
31+
)
2832
|> Map.get(:title)
2933
end
3034

31-
post
32-
|> Ash.Changeset.for_update(:update, %{title: "okay"}, authorize?: true)
33-
|> Ash.update!()
34-
|> Map.get(:title)
35+
# post
36+
# |> Ash.Changeset.for_update(:update, %{title: "okay"}, authorize?: true)
37+
# |> Ash.update!()
38+
# |> Map.get(:title)
3539
end
3640
end

test/calculation_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ defmodule AshPostgres.CalculationTest do
692692
Author
693693
|> Ash.Query.calculate(
694694
:length,
695-
expr(string_length(string_trim(first_name <> last_name <> " "))),
696-
:integer
695+
:integer,
696+
expr(string_length(string_trim(first_name <> last_name <> " ")))
697697
)
698698
|> Ash.read_one!()
699699
end
@@ -726,8 +726,8 @@ defmodule AshPostgres.CalculationTest do
726726
Author
727727
|> Ash.Query.calculate(
728728
:string,
729-
expr(lazy({__MODULE__, :fred, []})),
730-
:string
729+
:string,
730+
expr(lazy({__MODULE__, :fred, []}))
731731
)
732732
|> Ash.read_one!()
733733
end

test/error_expr_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ defmodule AshPostgres.ErrorExprTest do
2828
Post
2929
|> Ash.Query.calculate(
3030
:test,
31-
expr(error(Ash.Error.Query.InvalidFilterValue, message: "this is bad!", value: 10)),
32-
:string
31+
:string,
32+
expr(error(Ash.Error.Query.InvalidFilterValue, message: "this is bad!", value: 10))
3333
)
3434
|> Ash.read!()
3535
|> Enum.map(& &1.calculations)
@@ -46,8 +46,8 @@ defmodule AshPostgres.ErrorExprTest do
4646
Post
4747
|> Ash.Query.calculate(
4848
:test,
49-
expr(error(Ash.Error.Query.InvalidFilterValue, message: "this is bad!", value: 10)),
50-
:string
49+
:string,
50+
expr(error(Ash.Error.Query.InvalidFilterValue, message: "this is bad!", value: 10))
5151
)
5252
|> Ash.read!()
5353
|> Enum.map(& &1.calculations)

0 commit comments

Comments
 (0)