Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%Postgrex.Interval{} for the new :duration column type fails to load #706

Closed
VictorGaiva opened this issue Sep 6, 2024 · 1 comment
Closed
Labels

Comments

@VictorGaiva
Copy link

Elixir version

1.17.2

Database and Version

15.6

Postgrex Version

  • ecto (Hex package) (mix) locked at 3.12.2 (ecto) 492e67c7 * ecto_sql (Hex package) (mix) locked at 3.12.0 (ecto_sql) dc9e4d20

Current behavior

After adding a column with the following migration:

add(:duration, :duration, default: fragment("interval '1 day'"), null: false)

To a schema declared with:

field(:duration, :duration, default: Duration.new!(day: 1))

Running a test that inserts an entry,ecto fails to return a result, raising the following error:

** (ArgumentError) cannot load `%Postgrex.Interval{months: 0, days: 1, secs: 0, microsecs: 0}` as type :duration for field :duration in %Core....

Expected behavior

Since the value is correctly persisted to PostgreSQL, it should've also been loaded. It seems some mapping is missing.

Related to elixir-ecto/ecto_sql#631 and #688

@VictorGaiva
Copy link
Author

Fixed after adding interval_decode_type: Duration to Postgrex.Types.define, as described here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant