Skip to content

feat: add optional support for native Jiff timestamps - #13

Open
53v3n3d4 wants to merge 1 commit into
yugabyte:masterfrom
53v3n3d4:master
Open

53v3n3d4 wants to merge 1 commit into
yugabyte:masterfrom
53v3n3d4:master

Conversation

@53v3n3d4

Copy link
Copy Markdown

Summary

Adds optional support for the Jiff date-time library (0.2) by implementing ToSql and FromSql for its types, behind a new with-jiff-0_2 feature.

This is a port of the existing upstream implementation in rust-postgres/rust-postgres. It is not new design work, and the credit for the original goes to the upstream authors.

Supported types

Jiff type PostgreSQL type
jiff::Timestamp TIMESTAMPTZ
jiff::civil::DateTime TIMESTAMP
jiff::civil::Date DATE
jiff::civil::Time TIME

The Timestamp/Date wrappers for infinity / -infinity also work with these types. Without the wrapper, decoding an infinite value returns an error instead of panicking.

Usage

[dependencies]
yb-tokio-postgres = { version = "0.7.10-yb-1-beta.5", features = ["with-jiff-0_2"] }

Differences from upstream

  • This fork is based on an older tokio-postgres, where Error's Display still appends the cause. Because of that, test_special_params_without_wrapper asserts "error deserializing column 0: value too large to decode" rather than the shorter string used upstream after rust-postgres/rust-postgres@c5d3442.
  • I removed a duplicated query/assertion block in that test's helper.

Testing

cargo test -p yb-tokio-postgres --test test --features with-jiff-0_2 -- jiff
running 8 tests
test types::jiff_02::test_special_params_without_wrapper ... ok
test types::jiff_02::test_time_params ... ok
test types::jiff_02::test_datetime_params ... ok
test types::jiff_02::test_date_params ... ok
test types::jiff_02::test_with_special_datetime_params ... ok
test types::jiff_02::test_timestamp_params ... ok
test types::jiff_02::test_with_special_date_params ... ok
test types::jiff_02::test_with_special_timestamp_params ... ok

test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 101 filtered out

Tested against PostgreSQL 18 (Homebrew, macOS/aarch64).

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.

1 participant