From 1ee381640409aabaab1020547890ac68cf1ad9d3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 29 Nov 2023 14:37:36 -0800 Subject: [PATCH] Fixed tests --- R/select.R | 6 +----- tests/testthat/helper-in-time-zone.R | 6 +++++- tests/testthat/test-postgres.R | 2 +- tests/testthat/test-postgresql.R | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/select.R b/R/select.R index bd03a43..609421a 100644 --- a/R/select.R +++ b/R/select.R @@ -31,11 +31,7 @@ dbxSelect <- function(conn, statement, params=NULL) { # typecasting if (isRPostgreSQL(conn)) { sql_types <- tolower(column_info$type) - - if (storageTimeZone(conn) != currentTimeZone()) { - convert_tz <- which(sql_types == "timestamp") - } - + convert_tz <- which(sql_types == "timestamp") unescape_blobs <- which(sql_types == "bytea") fix_timetz <- which(sql_types == "timetzoid") } else if (isRPostgres(conn)) { diff --git a/tests/testthat/helper-in-time-zone.R b/tests/testthat/helper-in-time-zone.R index 6e17501..cb2e915 100644 --- a/tests/testthat/helper-in-time-zone.R +++ b/tests/testthat/helper-in-time-zone.R @@ -1,5 +1,5 @@ inTimeZone <- function(tz, code) { - previous_tz <- Sys.getenv("TZ", Sys.timezone()) + previous_tz <- currentTimeZone() tryCatch({ Sys.setenv(TZ=tz) eval(code) @@ -7,3 +7,7 @@ inTimeZone <- function(tz, code) { Sys.setenv(TZ=previous_tz) }) } + +currentTimeZone <- function() { + Sys.getenv("TZ", Sys.timezone()) +} diff --git a/tests/testthat/test-postgres.R b/tests/testthat/test-postgres.R index 0098782..cad329d 100644 --- a/tests/testthat/test-postgres.R +++ b/tests/testthat/test-postgres.R @@ -20,7 +20,7 @@ test_that("datetimes with storage_tz works", { dbxInsert(db2, "events", events) # for R-devel - attr(events$updated_at, "tzone") <- Sys.timezone() + attr(events$updated_at, "tzone") <- currentTimeZone() # test returned time res <- dbxSelect(db2, "SELECT * FROM events ORDER BY id") diff --git a/tests/testthat/test-postgresql.R b/tests/testthat/test-postgresql.R index 9e2b26c..750b250 100644 --- a/tests/testthat/test-postgresql.R +++ b/tests/testthat/test-postgresql.R @@ -24,7 +24,7 @@ test_that("datetimes with storage_tz works", { dbxInsert(db2, "events", events) # for R-devel - attr(events$updated_at, "tzone") <- Sys.timezone() + attr(events$updated_at, "tzone") <- currentTimeZone() # test returned time res <- dbxSelect(db2, "SELECT * FROM events ORDER BY id")