sql_strip_comments: sql_strip_comments

Description Usage Arguments Details See Also Examples

View source: R/sql_strip_comments.R

Description

Strip comments from a SQL STATEMENT

Usage

1
sql_strip_comments(sql, block = TRUE, inline = TRUE, ...)

Arguments

sql

connection or character;

block

logical; strip block (/* ... */) comments, default: TRUE

inline

logical; strip inline -- comments, default: TRUE

...

additional arguments passed to sql_read

Details

sql_strip_comments removes SQL standard comments from a SQL statement. Both inline (--) and block (/* ... */) style comments can be striped independently with the inline and block arguments, the default is to strip both style of comments. block comments are given priority and will remove any nested comments.

A single space preceding a comment is also stripped.

See Also

sql_read

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  # BLOCK COMMENTS
  sql <- "SELECT name /* User Name */ FROM table"
  sql_strip_comments( sql )

  sql <- "SELECT name /* User \n Name */ FROM table"
  sql_strip_comments( sql )

  sql <- "SELECT\n first_name, /* User First Name */\n last_name /* User Last Name */\n FROM table"
  sql_strip_comments( sql )

  # INLINE COMMENTS
  sql <- "SELECT -- comment \n A -- col A \n from \n table"
  sql_strip_comments( sql )

decisionpatterns/sql.template documentation built on July 6, 2020, 8:41 a.m.