@@ -57,6 +57,7 @@ postgres_grepl <- function(pattern,
5757 check_unsupported_arg(perl , FALSE , backend = " PostgreSQL" )
5858 check_unsupported_arg(fixed , FALSE , backend = " PostgreSQL" )
5959 check_unsupported_arg(useBytes , FALSE , backend = " PostgreSQL" )
60+ check_bool(ignore.case )
6061
6162 if (ignore.case ) {
6263 sql_expr(((!! x )) %~ * % ((!! pattern )))
@@ -123,6 +124,7 @@ sql_translation.PqConnection <- function(con) {
123124 },
124125 # https://www.postgresql.org/docs/current/functions-matching.html
125126 str_like = function (string , pattern , ignore_case = TRUE ) {
127+ check_bool(ignore_case )
126128 if (isTRUE(ignore_case )) {
127129 sql_expr(!! string %ILIKE % !! pattern )
128130 } else {
@@ -162,6 +164,9 @@ sql_translation.PqConnection <- function(con) {
162164 sql_expr(EXTRACT(DAY %FROM % !! x ))
163165 },
164166 wday = function (x , label = FALSE , abbr = TRUE , week_start = NULL ) {
167+ check_bool(label )
168+ check_bool(abbr )
169+ check_number_whole(week_start , allow_null = TRUE )
165170 if (! label ) {
166171 week_start <- week_start %|| % getOption(" lubridate.week.start" , 7 )
167172 offset <- as.integer(7 - week_start )
@@ -182,6 +187,8 @@ sql_translation.PqConnection <- function(con) {
182187 sql_expr(EXTRACT(WEEK %FROM % !! x ))
183188 },
184189 month = function (x , label = FALSE , abbr = TRUE ) {
190+ check_bool(label )
191+ check_bool(abbr )
185192 if (! label ) {
186193 sql_expr(EXTRACT(MONTH %FROM % !! x ))
187194 } else {
@@ -193,6 +200,7 @@ sql_translation.PqConnection <- function(con) {
193200 }
194201 },
195202 quarter = function (x , with_year = FALSE , fiscal_start = 1 ) {
203+ check_bool(with_year )
196204 check_unsupported_arg(fiscal_start , 1 , backend = " PostgreSQL" )
197205
198206 if (with_year ) {
@@ -246,17 +254,14 @@ sql_translation.PqConnection <- function(con) {
246254 glue_sql2(sql_current_con(), " ({.col x} + {.val n}*INTERVAL'1 year')" )
247255 },
248256 date_build = function (year , month = 1L , day = 1L , ... , invalid = NULL ) {
257+ check_unsupported_arg(invalid , allow_null = TRUE )
249258 sql_expr(make_date(!! year , !! month , !! day ))
250259 },
251260 date_count_between = function (start , end , precision , ... , n = 1L ){
252261
253262 check_dots_empty()
254- if (precision != " day" ) {
255- cli_abort(" {.arg precision} must be {.val day} on SQL backends." )
256- }
257- if (n != 1 ) {
258- cli_abort(" {.arg n} must be {.val 1} on SQL backends." )
259- }
263+ check_unsupported_arg(precision , allowed = " day" )
264+ check_unsupported_arg(n , allowed = 1L )
260265
261266 sql_expr(!! end - !! start )
262267 },
@@ -272,13 +277,8 @@ sql_translation.PqConnection <- function(con) {
272277
273278 difftime = function (time1 , time2 , tz , units = " days" ) {
274279
275- if (! missing(tz )) {
276- cli :: cli_abort(" The {.arg tz} argument is not supported for SQL backends." )
277- }
278-
279- if (units [1 ] != " days" ) {
280- cli :: cli_abort(' The only supported value for {.arg units} on SQL backends is "days"' )
281- }
280+ check_unsupported_arg(tz )
281+ check_unsupported_arg(units , allowed = " days" )
282282
283283 sql_expr((CAST(!! time1 %AS % DATE ) - CAST(!! time2 %AS % DATE )))
284284 },
@@ -344,6 +344,7 @@ sql_query_insert.PqConnection <- function(con,
344344 ... ,
345345 returning_cols = NULL ,
346346 method = NULL ) {
347+ check_string(method , allow_null = TRUE )
347348 method <- method %|| % " on_conflict"
348349 arg_match(method , c(" on_conflict" , " where_not_exists" ), error_arg = " method" )
349350 if (method == " where_not_exists" ) {
@@ -379,6 +380,7 @@ sql_query_upsert.PqConnection <- function(con,
379380 ... ,
380381 returning_cols = NULL ,
381382 method = NULL ) {
383+ check_string(method , allow_null = TRUE )
382384 method <- method %|| % " on_conflict"
383385 arg_match(method , c(" cte_update" , " on_conflict" ), error_arg = " method" )
384386
0 commit comments