Skip to content

Commit

Permalink
Merge pull request #346 from r-dbi/f-initial-immediate
Browse files Browse the repository at this point in the history
- `dbConnect()` executes initial queries with `immediate = TRUE` (#346).
  • Loading branch information
krlmlr authored Dec 4, 2021
2 parents 27e7cf9 + 0fe0bac commit 89a7b89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/PqConnection.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ setMethod("dbConnect", "PqDriver",
on.exit(dbDisconnect(conn))

# set datestyle workaround - https://github.com/r-dbi/RPostgres/issues/287
dbExecute(conn, "SET datestyle to 'iso, mdy'")
dbExecute(conn, "SET datestyle to 'iso, mdy'", immediate = TRUE)

if (!is.null(timezone)) {
# Side effect: check if time zone valid
dbExecute(conn, paste0("SET TIMEZONE = ", dbQuoteString(conn, timezone)))
dbExecute(conn, paste0("SET TIMEZONE = ", dbQuoteString(conn, timezone)), immediate = TRUE)
} else {
timezone <- dbGetQuery(conn, "SHOW timezone")[[1]]
timezone <- dbGetQuery(conn, "SHOW timezone", immediate = TRUE)[[1]]
}

# Check if this is a valid time zone in R:
Expand All @@ -224,7 +224,7 @@ setMethod("dbConnect", "PqDriver",

conn@timezone <- timezone
conn@timezone_out <- timezone_out
conn@typnames <- dbGetQuery(conn, "SELECT oid, typname FROM pg_type")
conn@typnames <- dbGetQuery(conn, "SELECT oid, typname FROM pg_type", immediate = TRUE)

on.exit(NULL)
conn
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-checkInterrupts.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ test_that("check_interrupts = TRUE works with queries > 1 second (#244)", {
test_that("check_interrupts = TRUE interrupts immediately (#336)", {
skip_if_not(postgresHasDefault())
skip_if(Sys.getenv("R_COVR") != "")

# https://github.com/r-lib/processx/issues/319
skip_on_os("windows")

session <- callr::r_session$new()
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-immediate.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ SELECT 1 AS a
test_that("immediate with interrupts after notice", {
skip_if_not(postgresHasDefault())
skip_if(Sys.getenv("R_COVR") != "")

# https://github.com/r-lib/processx/issues/319
skip_on_os("windows")

session <- callr::r_session$new()
Expand Down Expand Up @@ -153,6 +155,8 @@ $$
test_that("immediate with interrupts before notice", {
skip_if_not(postgresHasDefault())
skip_if(Sys.getenv("R_COVR") != "")

# https://github.com/r-lib/processx/issues/319
skip_on_os("windows")

session <- callr::r_session$new()
Expand Down

0 comments on commit 89a7b89

Please sign in to comment.