lamp-town-guy
lamp-town-guy
AEAsh Elixir
Created by lamp-town-guy on 3/16/2023 in #support
How to replace Ecto.Schema modifications?
OK I feel super dumb. default: &App.Type.EctoULID.generate/1 was supposed to be default: &App.Type.EctoULID.generate/0. Thanks, it's working now.
18 replies
AEAsh Elixir
Created by lamp-town-guy on 3/16/2023 in #support
How to replace Ecto.Schema modifications?
Well, I might contribute to phoenix guide because there are no error messages in the blog example. I expected it to be there. Default value is not being generated correctly.
errors: [
%Ash.Error.Changes.InvalidAttribute{
field: :id,
message: "is invalid",
private_vars: nil,
value: &App.Type.EctoULID.generate/1,
changeset: nil,
query: nil,
error_context: [],
vars: [field: :id, message: "is invalid"],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
],
errors: [
%Ash.Error.Changes.InvalidAttribute{
field: :id,
message: "is invalid",
private_vars: nil,
value: &App.Type.EctoULID.generate/1,
changeset: nil,
query: nil,
error_context: [],
vars: [field: :id, message: "is invalid"],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
],
18 replies
AEAsh Elixir
Created by lamp-town-guy on 3/16/2023 in #support
How to replace Ecto.Schema modifications?
Well, that's all I get when I want to create a blog post. I have nothing in the database so it should be created.
18 replies
AEAsh Elixir
Created by lamp-town-guy on 3/16/2023 in #support
How to replace Ecto.Schema modifications?
Thanks @kernel but in the end I've copied UUID and changed required parts. @Zach Daniel your snippet was useful but there were few things missing. Primary key and allow nil. I have ecto and ash types defined in different files which I might merge together.
attribute :id, App.Type.AshULID,
generated?: true,
default: &App.Type.EctoULID.generate/0,
primary_key?: true,
allow_nil?: false
attribute :id, App.Type.AshULID,
generated?: true,
default: &App.Type.EctoULID.generate/0,
primary_key?: true,
allow_nil?: false
But now when I try to create new post in Phoenix example I get this error:
[debug] HANDLE EVENT "create_post" in AppWeb.ExampleLiveView
Parameters: %{"" => "", "form" => %{"title" => "test"}}
[debug] QUERY OK source="posts" db=0.1ms idle=1995.5ms
SELECT p0."id", p0."inserted_at", p0."updated_at", p0."title", p0."content" FROM "posts" AS p0 []
↳ AshPostgres.DataLayer.run_query/2, at: lib/data_layer.ex:613
[debug] HANDLE EVENT "create_post" in AppWeb.ExampleLiveView
Parameters: %{"" => "", "form" => %{"title" => "test"}}
[debug] QUERY OK source="posts" db=0.1ms idle=1995.5ms
SELECT p0."id", p0."inserted_at", p0."updated_at", p0."title", p0."content" FROM "posts" AS p0 []
↳ AshPostgres.DataLayer.run_query/2, at: lib/data_layer.ex:613
How do I get to more verbose error message?
18 replies
AEAsh Elixir
Created by lamp-town-guy on 2/8/2023 in #support
module AshPostgres.DataLayer.CustomIndexes is not loaded and could not be found
Old version of ash. I've had 2.5.6 and current is 2.6. Which solved my problem. I needed to install newer version of Elixir from asdf. But now it works.
5 replies