erlangbureau / jamdb_oracle

Oracle Database driver for Erlang
MIT License
103 stars 46 forks source link

Error loading rows that used the :identity primary key type in create table migration #148

Closed dfrese closed 5 months ago

dfrese commented 9 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:

  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:

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

      @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!

vstavskyi commented 9 months ago

integer generated by default as identity Looks better

vstavskyi commented 9 months ago

fixed