Skip to content

Add an integration test for non-UTC timestamptz (Postgres) #1482

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/postgres/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,23 @@ async fn it_can_prepare_then_execute() -> anyhow::Result<()> {
Ok(())
}

#[sqlx_macros::test]
async fn it_can_convert_non_utc_timestamptz() -> anyhow::Result<()> {
use sqlx::types::chrono::{DateTime, TimeZone, Utc};
let mut conn = new::<Postgres>().await?;
let date = Utc.ymd(2020, 1, 1).and_hms(1, 1, 1);
sqlx::query("SET TIME ZONE 'Europe/Berlin'")
.fetch_optional(&mut conn)
.await?;
let row: (DateTime<Utc>,) = sqlx::query_as("SELECT $1::timestamptz")
.bind(&date)
.fetch_one(&mut conn)
.await?;
assert_eq!(row.0, date);

Ok(())
}

// repro is more reliable with the basic scheduler used by `#[tokio::test]`
#[cfg(feature = "_rt-tokio")]
#[tokio::test]
Expand Down