Skip to content

Conversation

@the-kenny
Copy link

This implements Normalizable for NaiveDate to support Range<Date>. It also changes assert! to assert_eq! in a few places to improve the test output.

Note that I had to #[ignore] the new test I added because Postgres normalises (2023-01-01,) to [2023-01-02,), which makes the test fail as test_types does a by-value comparison.

> The built-in range types int4range, int8range,
> and daterange all use a canonical form that
> includes the lower bound and excludes the upper
> bound; that is, [).

https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-DISCRETE

This is implemented by modifying the
`bounded_normalize` macro to take a `$delta`
expression (`1` for `i32` and `i64`,
`Duration::days(1)` for `NaiveDate`).
@the-kenny
Copy link
Author

@sfackler I finally got around to fixing Normalize :-) Could I ask you to have another look when your time permits?

@lgrosz
Copy link

lgrosz commented Mar 24, 2025

Will this get merged?

lgrosz added a commit to lgrosz/climb-graphql that referenced this pull request Mar 24, 2025
This _does not_ add the date window support, yet. This is because there
is not a great native rust-postgres way of getting PostgreSQLs DATERANGE
type. Looks like there's rust-postgres/rust-postgres-range#18, but it hasn't
been merged in a year and the general state of rust-postgres-range seems
unmaintained.. perhaps @tkbrigham has a good point in
rust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQL
features were supported in rust-postgres directly.
lgrosz added a commit to lgrosz/climb-graphql that referenced this pull request Mar 24, 2025
This _does not_ add the date window support, yet. This is because there
is not a great native rust-postgres way of getting PostgreSQLs DATERANGE
type. Looks like there's rust-postgres/rust-postgres-range#18, but it hasn't
been merged in a year and the general state of rust-postgres-range seems
unmaintained.. perhaps @tkbrigham has a good point in
rust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQL
features were supported in rust-postgres directly.
lgrosz added a commit to lgrosz/climb-graphql that referenced this pull request Mar 25, 2025
This _does not_ add the date window support, yet. This is because there
is not a great native rust-postgres way of getting PostgreSQLs DATERANGE
type. Looks like there's rust-postgres/rust-postgres-range#18, but it hasn't
been merged in a year and the general state of rust-postgres-range seems
unmaintained.. perhaps @tkbrigham has a good point in
rust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQL
features were supported in rust-postgres directly.
lgrosz added a commit to lgrosz/climb-graphql that referenced this pull request Mar 28, 2025
This _does not_ add the date window support, yet. This is because there
is not a great native rust-postgres way of getting PostgreSQLs DATERANGE
type. Looks like there's rust-postgres/rust-postgres-range#18, but it hasn't
been merged in a year and the general state of rust-postgres-range seems
unmaintained.. perhaps @tkbrigham has a good point in
rust-postgres/rust-postgres#601.. it'd be great if all the PostgreSQL
features were supported in rust-postgres directly.
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.

3 participants