Closed dfrese closed 10 months ago
Hi!
I used the :identity primary key type to create a table via ecto.migrate. That uses number as the column type as defined in:
:identity
number
defp ecto_to_db(:identity), do: "number generated by default as identity"
But after inserting a row like that, there is a problem reading that via Ecto.Repo. The error is raised at Ecto.Repo.Queryable.struct_load!/6:
Ecto.Repo.Queryable.struct_load!/6
cannot load `1.0` as type :id for field :id in %MySchema...
Seems the is is somehow read as a floating point number. The schema MySchema was defined with
MySchema
@primary_key {:id, :id, autogenerate: true}
When I use :"number(38,0) generated by default as identity" as the primary key column type, it all works fine!
:"number(38,0) generated by default as identity"
integer generated by default as identity Looks better
integer generated by default as identity
fixed
Hi!
I used the
:identity
primary key type to create a table via ecto.migrate. That usesnumber
as the column type as defined in:But after inserting a row like that, there is a problem reading that via Ecto.Repo. The error is raised at
Ecto.Repo.Queryable.struct_load!/6
:Seems the is is somehow read as a floating point number. The schema
MySchema
was defined withWhen I use
:"number(38,0) generated by default as identity"
as the primary key column type, it all works fine!