Compile error: module Any is reserved and cannot be defined
Say I have the following resources:
City:
State:
Region:
Credo seems to complain about state, saying:
Not really sure what to do about that.
City:
# myapp/lib/myapp/data/resources/city.ex
defmodule MyApp.Data.City do
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :id
attribute :name, :string do
allow_nil? false
end
end
relationships do
has_one :state, MyApp.Data.State
end
end# myapp/lib/myapp/data/resources/city.ex
defmodule MyApp.Data.City do
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :id
attribute :name, :string do
allow_nil? false
end
end
relationships do
has_one :state, MyApp.Data.State
end
endState:
defmodule MyApp.Data.State do
@moduledoc false
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :state_id
attribute :name, :string do
allow_nil? false
end
attribute :url, :string do
allow_nil? true
end
end
relationships do
has_one :region, MyApp.Data.Region
end
enddefmodule MyApp.Data.State do
@moduledoc false
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :state_id
attribute :name, :string do
allow_nil? false
end
attribute :url, :string do
allow_nil? true
end
end
relationships do
has_one :region, MyApp.Data.Region
end
endRegion:
defmodule MyApp.Data.Region do
@moduledoc false
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :region_id
attribute :name, :string do
allow_nil? false
end
end
enddefmodule MyApp.Data.Region do
@moduledoc false
use Ash.Resource
actions do
defaults [:create, :update, :read, :destroy]
end
attributes do
uuid_primary_key :region_id
attribute :name, :string do
allow_nil? false
end
end
endCredo seems to complain about state, saying:
** (CompileError) iex:1: module Any is reserved and cannot be defined
Elixir reserves the following module names: Elixir, Any, BitString, PID, and Reference.
(ArgumentError) schema does not have the field :id used by association :region, please set the :references option accordingly
Stacktrace:
│ (ecto 3.9.4) lib/ecto/association.ex:696: Ecto.Association.Has.struct/3
│ (ecto 3.9.4) lib/ecto/schema.ex:1879: Ecto.Schema.association/5
│ (ecto 3.9.4) lib/ecto/schema.ex:2006: Ecto.Schema.__has_one__/4
│ /Users/alec-s/Projects/myapp/lib/myapp/data/resources/state.ex:1: (file)
│ /Users/alec-s/Projects/myapp/lib/myapp/data/resources/state.ex:1: (file)
│ (stdlib 4.2) erl_eval.erl:748: :erl_eval.do_apply/7
│ (stdlib 4.2) erl_eval.erl:136: :erl_eval.exprs/6Elixir** (CompileError) iex:1: module Any is reserved and cannot be defined
Elixir reserves the following module names: Elixir, Any, BitString, PID, and Reference.
(ArgumentError) schema does not have the field :id used by association :region, please set the :references option accordingly
Stacktrace:
│ (ecto 3.9.4) lib/ecto/association.ex:696: Ecto.Association.Has.struct/3
│ (ecto 3.9.4) lib/ecto/schema.ex:1879: Ecto.Schema.association/5
│ (ecto 3.9.4) lib/ecto/schema.ex:2006: Ecto.Schema.__has_one__/4
│ /Users/alec-s/Projects/myapp/lib/myapp/data/resources/state.ex:1: (file)
│ /Users/alec-s/Projects/myapp/lib/myapp/data/resources/state.ex:1: (file)
│ (stdlib 4.2) erl_eval.erl:748: :erl_eval.do_apply/7
│ (stdlib 4.2) erl_eval.erl:136: :erl_eval.exprs/6ElixirNot really sure what to do about that.
