@@ -84,62 +84,65 @@ spec_arrow_get_query_arrow <- list(
84
84
expect_equal(out , head(result , nrow(out )))
85
85
},
86
86
87
- # #' @section Additional arguments:
88
- # #' The following arguments are not part of the `dbGetQueryArrow()` generic
89
- # #' (to improve compatibility across backends)
90
- # #' but are part of the DBI specification:
91
- # #' - `params` (default: `NULL`)
92
- # #' - `immediate` (default: `NULL`)
93
- # #'
94
- # #' They must be provided as named arguments.
95
- # #' See the "Specification" and "Value" sections for details on their usage.
96
- #
97
- # #'
98
- # arrow_get_query_arrow_params = function(ctx, con) {
99
- # #' The `param` argument allows passing query parameters, see [dbBind()] for details.
100
- # placeholder_funs <- get_placeholder_funs(ctx)
101
- #
102
- # for (placeholder_fun in placeholder_funs) {
103
- # placeholder <- placeholder_fun(1)
104
- # query <- paste0("SELECT ", placeholder, " + 1.0 AS a")
105
- # values <- trivial_values(3) - 1
106
- # params <- stats::setNames(list(values), names(placeholder))
107
- # ret <- dbGetQueryArrow(con, query, params = params)
108
- # expect_equal(ret, trivial_df(3), info = placeholder)
109
- # }
110
- # },
87
+ # ' @section Additional arguments:
88
+ # ' The following arguments are not part of the `dbGetQueryArrow()` generic
89
+ # ' (to improve compatibility across backends)
90
+ # ' but are part of the DBI specification:
91
+ # ' - `params` (default: `NULL`)
92
+ # ' - `immediate` (default: `NULL`)
93
+ # '
94
+ # ' They must be provided as named arguments.
95
+ # ' See the "Specification" and "Value" sections for details on their usage.
96
+ # '
97
+ arrow_get_query_arrow_params = function (ctx , con ) {
98
+ skip_if(ctx $ tweaks $ dbitest_version < " 1.8.0.1" )
99
+
100
+ # ' The `param` argument allows passing query parameters, see [dbBind()] for details.
101
+ placeholder_funs <- get_placeholder_funs(ctx )
102
+
103
+ for (placeholder_fun in placeholder_funs ) {
104
+ placeholder <- placeholder_fun(1 )
105
+ query <- paste0(" SELECT " , placeholder , " + 1.0 AS a" )
106
+ values <- trivial_values(3 ) - 1
107
+ params <- stats :: setNames(list (values ), names(placeholder ))
108
+ ret <- dbGetQueryArrow(con , query , params = params )
109
+ expect_equal(ret , trivial_df(3 ), info = placeholder )
110
+ }
111
+ },
111
112
#
112
- # arrow_get_query_arrow_immediate = function(con, table_name) {
113
- # #' @section Specification for the `immediate` argument:
114
- # #'
115
- # #' The `immediate` argument supports distinguishing between "direct"
116
- # #' and "prepared" APIs offered by many database drivers.
117
- # #' Passing `immediate = TRUE` leads to immediate execution of the
118
- # #' query or statement, via the "direct" API (if supported by the driver).
119
- # #' The default `NULL` means that the backend should choose whatever API
120
- # #' makes the most sense for the database, and (if relevant) tries the
121
- # #' other API if the first attempt fails. A successful second attempt
122
- # #' should result in a message that suggests passing the correct
123
- # #' `immediate` argument.
124
- # #' Examples for possible behaviors:
125
- # #' 1. DBI backend defaults to `immediate = TRUE` internally
126
- # #' 1. A query without parameters is passed: query is executed
127
- # #' 1. A query with parameters is passed:
128
- # #' 1. `params` not given: rejected immediately by the database
129
- # #' because of a syntax error in the query, the backend tries
130
- # #' `immediate = FALSE` (and gives a message)
131
- # #' 1. `params` given: query is executed using `immediate = FALSE`
132
- # #' 1. DBI backend defaults to `immediate = FALSE` internally
133
- # #' 1. A query without parameters is passed:
134
- # #' 1. simple query: query is executed
135
- # #' 1. "special" query (such as setting a config options): fails,
136
- # #' the backend tries `immediate = TRUE` (and gives a message)
137
- # #' 1. A query with parameters is passed:
138
- # #' 1. `params` not given: waiting for parameters via [dbBind()]
139
- # #' 1. `params` given: query is executed
140
- # res <- expect_visible(dbGetQueryArrow(con, trivial_query(), immediate = TRUE))
141
- # expect_s3_class(res, "data.frame")
142
- # },
113
+ arrow_get_query_arrow_immediate = function (ctx , con , table_name ) {
114
+ skip_if(ctx $ tweaks $ dbitest_version < " 1.8.0.2" )
115
+
116
+ # ' @section Specification for the `immediate` argument:
117
+ # '
118
+ # ' The `immediate` argument supports distinguishing between "direct"
119
+ # ' and "prepared" APIs offered by many database drivers.
120
+ # ' Passing `immediate = TRUE` leads to immediate execution of the
121
+ # ' query or statement, via the "direct" API (if supported by the driver).
122
+ # ' The default `NULL` means that the backend should choose whatever API
123
+ # ' makes the most sense for the database, and (if relevant) tries the
124
+ # ' other API if the first attempt fails. A successful second attempt
125
+ # ' should result in a message that suggests passing the correct
126
+ # ' `immediate` argument.
127
+ # ' Examples for possible behaviors:
128
+ # ' 1. DBI backend defaults to `immediate = TRUE` internally
129
+ # ' 1. A query without parameters is passed: query is executed
130
+ # ' 1. A query with parameters is passed:
131
+ # ' 1. `params` not given: rejected immediately by the database
132
+ # ' because of a syntax error in the query, the backend tries
133
+ # ' `immediate = FALSE` (and gives a message)
134
+ # ' 1. `params` given: query is executed using `immediate = FALSE`
135
+ # ' 1. DBI backend defaults to `immediate = FALSE` internally
136
+ # ' 1. A query without parameters is passed:
137
+ # ' 1. simple query: query is executed
138
+ # ' 1. "special" query (such as setting a config options): fails,
139
+ # ' the backend tries `immediate = TRUE` (and gives a message)
140
+ # ' 1. A query with parameters is passed:
141
+ # ' 1. `params` not given: waiting for parameters via [dbBind()]
142
+ # ' 1. `params` given: query is executed
143
+ res <- expect_visible(dbGetQueryArrow(con , trivial_query(), immediate = TRUE ))
144
+ expect_s3_class(res , " data.frame" )
145
+ },
143
146
#
144
147
NULL
145
148
)
0 commit comments