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

Relax restriction on allowed year for Date #687

Closed
linusdm opened this issue Jul 5, 2024 · 1 comment
Closed

Relax restriction on allowed year for Date #687

linusdm opened this issue Jul 5, 2024 · 1 comment
Labels

Comments

@linusdm
Copy link

linusdm commented Jul 5, 2024

Elixir version

1.17.0

Database and Version

PostgreSQL 15.0

Postgrex Version

0.18.0

Current behavior

{:ok, pid} = Postgrex.start_link(hostname: "localhost", username: "postgres", password: "postgres")
Postgrex.query!(pid, "SELECT $1::DATE", [Date.new!(9_999, 12, 31)])
Postgrex.query!(pid, "SELECT $1::DATE", [Date.new!(10_000, 1, 1)])

The last query results in

** (ArgumentError) Date.new!(10000, 1, 1) is beyond the maximum year 9999
    (postgrex 0.18.0) lib/postgrex/extensions/date.ex:41: Postgrex.Extensions.Date.encode_elixir/1
    (postgrex 0.18.0) lib/postgrex/type_module.ex:947: Postgrex.DefaultTypes.encode_params/3

Expected behavior

Elixir 1.17 allows a Date to be outside the -9999..9999 range.

Postgrex seems to have this maximum year (not a minimum…) hard-coded when dealing with Dates.
Should the handling of Dates be changed to be in accordance with the new way of handling years in Elixir 1.17? Or are there other constraints in play here that are imposed by Postgres?

@greg-rychlewski
Copy link
Member

I think we need to remove it from timestamptz as well. That one looks like a more involved change though.

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

2 participants