Skip to content

Add Infinity check functions#4295

Open
firebladed wants to merge 6 commits into
transact-rs:mainfrom
firebladed:pginterval-infinity
Open

Add Infinity check functions#4295
firebladed wants to merge 6 commits into
transact-rs:mainfrom
firebladed:pginterval-infinity

Conversation

@firebladed

Copy link
Copy Markdown

Added ability to check if interval defined as +/- infinity

Adds two functions

  • is_infinite()
  • is_positive_infinity()

based on descriptions in https://www.postgresql.org/message-id/E1r2rB1-005PHm-UL%40gemulon.postgresql.org

  • is_negative_infinity() is possible addition if beneficial

Am new to rust so please point out any improvements

Does your PR solve an issue?

No
can create one is useful for tracking, but as could not find one and looks simple enough to fix directly

Is this a breaking change?

No, Do not believe so

@abonander abonander left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add cases to the integration test as well?

test_prepared_type!(interval<PgInterval>(
Postgres,
"INTERVAL '1h'"
== PgInterval {
months: 0,
days: 0,
microseconds: 3_600_000_000
},
"INTERVAL '-1 hours'"
== PgInterval {
months: 0,
days: 0,
microseconds: -3_600_000_000
},
"INTERVAL '3 months 12 days 1h 15 minutes 10 second '"
== PgInterval {
months: 3,
days: 12,
microseconds: (3_600 + 15 * 60 + 10) * 1_000_000
},
"INTERVAL '03:10:20.116100'"
== PgInterval {
months: 0,
days: 0,
microseconds: (3 * 3_600 + 10 * 60 + 20) * 1_000_000 + 116100
},
));

@firebladed

Copy link
Copy Markdown
Author

added infinity and -infinity value tests, but not sure how to account for postgress sql version (>= 17)

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