Skip to content

Conversation

@greg-rychlewski
Copy link
Member

@greg-rychlewski greg-rychlewski commented Jan 20, 2026

There were a couple of people asking for this so I took a stab.

There is one thing I think can be debated. For timestamps we have an option to opt into infinity values. I'm not 100% sure the reason so I'm not sure if it's the right thing to do for intervals.

One reason I can see for adding an option is if people were using these values in the past as a proxy for +/- infinity and now they will be returned as atoms instead of structs. But on the flipside most people will probably want the atoms if they are using this behaviour and if we make it opt in it will be more annoying. So I was thinking it might make sense to leave it like this and then add an opt out option if people are having issues.

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit torn if we should do it like this or encode them in Postrex.Interval. Or perhaps make them opt-in?

@josevalim
Copy link
Member

Ah, yes, we do this for timestamps:

def init(opts), do: Keyword.get(opts, :allow_infinite_timestamps, false)

So we shoud have allow_infinite_intervals. And potentially allow_non_finite_floats, if we want to apply the same for floats.

@greg-rychlewski
Copy link
Member Author

@josevalim done!

other ->
raise ArgumentError,
"#{inspect(other)} is not valid for `:interval_decode_type`. Please use either `Postgrex.Interval` or `Duration`"
unless type in [Postgrex.Interval, Duration] do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless type in [Postgrex.Interval, Duration] do
if type not in [Postgrex.Interval, Duration] do

@greg-rychlewski greg-rychlewski merged commit b3e895a into elixir-ecto:master Jan 20, 2026
13 checks passed
@greg-rychlewski greg-rychlewski deleted the infinite_duration branch January 20, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants