** (DBConnection.EncodeError) Postgrex expected an integer in -2147483648..2147483647, got 277654884471

As far as I can tell from Ecto’s codebase, integers are always mapped as bigint. If I’m reading this correctly why the EncodeError?

1 Like

It would be good to know more context about the error. I’ve seen this error before, when trying to find an entity by id, passing a bad value.

Example: trying to get user by id, passing a number bigger than max integer.

Ecto, yes, but db… no.

You should show your migration file, and change to the appropriate db type :slight_smile:

@rodrigues @kokolegorille

Thank you both for your observations :slight_smile:

The figure “277654884471” is the result of a calculation. In both the migration and schema this figure is assigned the datatype :integer. What data type should be used instead?

:bigint is the type You are looking for.

UPDATE: I forgot to mention it’s for the migration file, but @benwilson512 did it for me :slight_smile:

3 Likes

:bigint in the migration, :integer in the schema. The migration is about the database types, and the schema is about the Elixir type.

5 Likes

Thank you everyone for your kind and timely assistance! :slight_smile: