Merge pull request #6815 from influxdata/dom/utc-db

feat(catalog): use explicit UTC time zone
pull/24376/head
Dom 2023-02-02 11:43:54 +00:00 committed by GitHub
commit 4da6b8adf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -405,6 +405,10 @@ async fn new_raw_pool(
}
let search_path_query = format!("SET search_path TO {},public;", schema_name);
c.execute(sqlx::query(&search_path_query)).await?;
// Ensure explicit timezone selection, instead of deferring to
// the server value.
c.execute("SET timezone = 'UTC';").await?;
Ok(())
})
})
@ -2556,8 +2560,15 @@ mod tests {
maybe_skip_integration!();
let postgres = setup_db().await;
let postgres: Arc<dyn Catalog> = Arc::new(postgres);
// Validate the connection time zone is the expected UTC value.
let tz: String = sqlx::query_scalar("SHOW TIME ZONE;")
.fetch_one(&postgres.pool)
.await
.expect("read application_name");
assert_eq!(tz, "UTC");
let postgres: Arc<dyn Catalog> = Arc::new(postgres);
crate::interface::test_helpers::test_catalog(postgres).await;
}