Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 29, 2023
1 parent 022e434 commit 1ee3816
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions R/select.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/helper-in-time-zone.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
inTimeZone <- function(tz, code) {
previous_tz <- Sys.getenv("TZ", Sys.timezone())
previous_tz <- currentTimeZone()
tryCatch({
Sys.setenv(TZ=tz)
eval(code)
}, finally={
Sys.setenv(TZ=previous_tz)
})
}

currentTimeZone <- function() {
Sys.getenv("TZ", Sys.timezone())
}
2 changes: 1 addition & 1 deletion tests/testthat/test-postgres.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-postgresql.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1ee3816

Please sign in to comment.