This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 79503e90 fix(r/adbcdrivermanager): Add format method for adbc_xptr
(#1165)
79503e90 is described below
commit 79503e906f21c1ffb5a966182394e7e1d8e977d5
Author: Dewey Dunnington <[email protected]>
AuthorDate: Thu Oct 5 11:04:02 2023 -0300
fix(r/adbcdrivermanager): Add format method for adbc_xptr (#1165)
It seems that in R 3.6 there is no default `format()` method for an
external pointer, which results in test/check failures that involve
printing a repr of a database/connection/statement.
---
r/adbcdrivermanager/NAMESPACE | 1 +
r/adbcdrivermanager/R/utils.R | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/r/adbcdrivermanager/NAMESPACE b/r/adbcdrivermanager/NAMESPACE
index f594bd3b..48a0aa94 100644
--- a/r/adbcdrivermanager/NAMESPACE
+++ b/r/adbcdrivermanager/NAMESPACE
@@ -18,6 +18,7 @@ S3method(adbc_statement_init,adbc_connection_log)
S3method(adbc_statement_init,adbc_connection_monkey)
S3method(adbc_statement_init,default)
S3method(execute_adbc,default)
+S3method(format,adbc_xptr)
S3method(length,adbc_error)
S3method(length,adbc_xptr)
S3method(names,adbc_error)
diff --git a/r/adbcdrivermanager/R/utils.R b/r/adbcdrivermanager/R/utils.R
index b46e266b..6caa8228 100644
--- a/r/adbcdrivermanager/R/utils.R
+++ b/r/adbcdrivermanager/R/utils.R
@@ -80,11 +80,19 @@ print.adbc_xptr <- function(x, ...) {
str(x, ...)
}
+#' @export
+format.adbc_xptr <- function(x, ...) {
+ sprintf(
+ "<%s at %s> ",
+ class(x)[1],
+ nanoarrow::nanoarrow_pointer_addr_pretty(x)
+ )
+}
+
#' @export
str.adbc_xptr <- function(object, ...) {
- cat(sprintf("<%s> %s ", class(object)[1], format(object)))
+ cat(sprintf("%s\n", format(object)))
env_proxy <- as.list(xptr_env(object))
- env_proxy$options <- as.list(env_proxy$options)
str(env_proxy, ...)
invisible(object)
}