Presently, the many_to_one and one_to_one fields only work when the targetted model has an integer primary key field.
Let's ensure that it is possible to target any kind of model, regardless of its primary key field. For example, it should be possible to define many_to_one and one_to_one fields targeting models with UUID primary keys:
class Article < Marten::Model
field :id, :uuid, primary_key: true
field :title, :string, max_size: 255
field :body, :text
after_initialize :initialize_id
private def initialize_id
@id ||= UUID.random
end
end
class Comment < Marten::Model
field :id, :int, primary_key: true, auto: true
field :article, :many_to_one, to: Article
field :text, :text
end
Description
Presently, the
many_to_one
andone_to_one
fields only work when the targetted model has an integer primary key field.Let's ensure that it is possible to target any kind of model, regardless of its primary key field. For example, it should be possible to define
many_to_one
andone_to_one
fields targeting models with UUID primary keys: