You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writing SQL is a lot of pasting-together strings. The SQL() function provides a nice entry point to mark character vectors as SQL (which will result in nicer printing).
If we have a way to mark text as SQL would it not be nice to be able to do something 'simply' put together parts of an SQL-statement in an easy manner?
The Solution
SQL() in combination with overloading the plus operator might bring a lot of productivity gain here.
#' +-Operator for SQL#' #' Pastes together two character vectors marked as SQL (via \code{SQL()}). #' #' @param a first part of SQL statement#' @param b second part of SQL statement#'#' @export#' @examples#' #' ## SQL("SELECT * FROM mytable ") + "WHERE id ='" + 1:10 + "'"#' ## <SQL> SELECT * FROM mytable WHERE id ='1'#' ## <SQL> SELECT * FROM mytable WHERE id ='2'#' ## <SQL> SELECT * FROM mytable WHERE id ='3'#' ## <SQL> SELECT * FROM mytable WHERE id ='4'#' ## <SQL> SELECT * FROM mytable WHERE id ='5'#' ## <SQL> SELECT * FROM mytable WHERE id ='6'#' ## <SQL> SELECT * FROM mytable WHERE id ='7'#' ## <SQL> SELECT * FROM mytable WHERE id ='8'#' ## <SQL> SELECT * FROM mytable WHERE id ='9'#' ## <SQL> SELECT * FROM mytable WHERE id ='10'#' "+.SQL"<-function(a,b) {SQL(paste0(a,b))}
The text was updated successfully, but these errors were encountered:
Thanks. If dbx adopts dbxSQL(), the + operator (perhaps implemented as S4 method?) could also live there. I'd rather not expand DBI in this direction at this time.
The Problem
Writing SQL is a lot of pasting-together strings. The SQL() function provides a nice entry point to mark character vectors as SQL (which will result in nicer printing).
If we have a way to mark text as SQL would it not be nice to be able to do something 'simply' put together parts of an SQL-statement in an easy manner?
The Solution
SQL() in combination with overloading the plus operator might bring a lot of productivity gain here.
The text was updated successfully, but these errors were encountered: