Ash FrameworkAF
Ash Framework3y ago
20 replies
tellesleandro

belongs_to does not add _id attributes do resource

The resource with attributes and relationships
attributes do
  uuid_primary_key :id
  create_timestamp :inserted_at
  update_timestamp :updated_at
  attribute :max_estadias_simultaneas, :integer do
    allow_nil? false
    default 1
  end
  attribute :valido_ate, :utc_datetime_usec
  attribute :chaves, {:array, :string} do
    allow_nil? false
    default []
  end
end

relationships do
  belongs_to :plano, Garagem.Operacional.Plano
  belongs_to :pessoa, Garagem.Operacional.Pessoa
end

does not have the attributes plano_id and pessoa_id.

If I try to insert a record, the insert command does not have the foreign keys:
INSERT INTO "planos_contratos" ("chaves","id","inserted_at","max_estadias_simultaneas","updated_at","valido_ate") VALUES ($1,$2,$3,$4,$5,$6) [[], "a0424503-341b-476d-8522-926f600457c7", ~U[2023-09-26 04:33:13.460031Z], 1, ~U[2023-09-26 04:33:13.460031Z], ~U[2023-09-26 04:33:13.084948Z]]
Was this page helpful?