diff --git a/R/location.R b/R/location.R index 7874ae20..e086f1be 100644 --- a/R/location.R +++ b/R/location.R @@ -349,7 +349,7 @@ orderly_location_pull_packet <- function(expr, allow_remote = TRUE, pull_metadata = pull_metadata) - if (is.character(expr) && is.null(name) && all(grepl(re_id, expr))) { + if (expr_is_literal_id(expr, name)) { ids <- expr } else { ## TODO: we may drop options here diff --git a/R/outpack_tools.R b/R/outpack_tools.R index 7a2ae3f1..a0ead672 100644 --- a/R/outpack_tools.R +++ b/R/outpack_tools.R @@ -182,27 +182,32 @@ ##' ##' @title Extract metadata from orderly2 packets ##' -##' @param ... Arguments passed through to -##' [orderly2::orderly_search]. In the special case where the first -##' argument is a character vector of ids *and* there are no named -##' dot arguments, then we interpret this argument as a vector of -##' ids directly. -##' ##' @param extract A character vector of columns to extract, possibly ##' named. See Details for the format. ##' ##' @inheritParams orderly_metadata +##' @inheritParams orderly_search ##' ##' @return A `data.frame`, the columns of which vary based on the ##' names of `extract`; see Details for more information. ##' ##' @export -orderly_metadata_extract <- function(..., extract = NULL, root = NULL) { +orderly_metadata_extract <- function(expr = NULL, name = NULL, location = NULL, + allow_remote = NULL, pull_metadata = FALSE, + extract = NULL, root = NULL) { root <- root_open(root, require_orderly = FALSE) - if (dots_is_literal_id(...)) { - ids <- ..1 + + options <- orderly_search_options(location = location, + allow_remote = allow_remote, + pull_metadata = pull_metadata) + if (expr_is_literal_id(expr, name)) { + ids <- expr } else { - ids <- orderly_search(..., root = root) + ## TODO: we may drop options here + ids <- orderly_search(expr, name = name, + options = options, + # location = location, pull_metadata = pull_metadata, + root = root) } extract <- parse_extract(extract, environment()) diff --git a/R/query.R b/R/query.R index 1be14753..811ab934 100644 --- a/R/query.R +++ b/R/query.R @@ -55,6 +55,13 @@ dots_is_literal_id <- function(...) { } +expr_is_literal_id <- function(expr, ...) { + all(vlapply(list(...), is.null)) && + is.character(expr) && + all(grepl(re_id, expr)) +} + + as_orderly_query <- function(expr, name = NULL, scope = NULL, subquery = NULL, arg = "expr", call = parent.frame()) { if (missing(expr)) { diff --git a/man/orderly_metadata_extract.Rd b/man/orderly_metadata_extract.Rd index 31f9f8ca..da2e027a 100644 --- a/man/orderly_metadata_extract.Rd +++ b/man/orderly_metadata_extract.Rd @@ -4,14 +4,22 @@ \alias{orderly_metadata_extract} \title{Extract metadata from orderly2 packets} \usage{ -orderly_metadata_extract(..., extract = NULL, root = NULL) +orderly_metadata_extract( + expr = NULL, + name = NULL, + location = NULL, + allow_remote = NULL, + pull_metadata = FALSE, + extract = NULL, + root = NULL +) } \arguments{ -\item{...}{Arguments passed through to -\link{orderly_search}. In the special case where the first -argument is a character vector of ids \emph{and} there are no named -dot arguments, then we interpret this argument as a vector of -ids directly.} +\item{expr}{The query expression. A \code{NULL} expression matches everything.} + +\item{name}{Optionally, the name of the packet to scope the query on. This +will be intersected with \code{scope} arg and is a shorthand way of running +\code{scope = list(name = "name")}} \item{extract}{A character vector of columns to extract, possibly named. See Details for the format.}