R/dbFetch_PqResult.R

Defines functions dbFetch_PqResult

Documented in dbFetch_PqResult

#' @param res Code a [PqResult-class] produced by
#'   [DBI::dbSendQuery()].
#' @param n Number of rows to return. If less than zero returns all rows.
#' @inheritParams DBI::sqlRownamesToColumn
#' @rdname postgres-query
#' @usage NULL
dbFetch_PqResult <- function(res, n = -1, ..., row.names = FALSE) {
  if (length(n) != 1) stopc("n must be scalar")
  if (n < -1) stopc("n must be nonnegative or -1")
  if (is.infinite(n)) n <- -1
  if (trunc(n) != n) stopc("n must be a whole number")
  ret <- sqlColumnToRownames(result_fetch(res@ptr, n = n), row.names)
  ret <- convert_bigint(ret, res@bigint)
  ret <- finalize_types(ret, res@conn)
  ret <- fix_timezone(ret, res@conn)
  set_tidy_names(ret)
}

#' @rdname postgres-query
#' @export
setMethod("dbFetch", "PqResult", dbFetch_PqResult)

Try the RPostgres package in your browser

Any scripts or data that you put into this service are public.

RPostgres documentation built on Oct. 23, 2023, 1:06 a.m.