Skip to content

Commit

Permalink
Style code (GHA)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwilsonsco committed Sep 10, 2024
1 parent 44e175e commit 8767a1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
28 changes: 14 additions & 14 deletions R/delete_table_rows.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
delete_sql <- function(schema, table_name){
delete_sql <- function(schema, table_name) {
glue::glue_sql("DELETE FROM {`schema`}.{`table_name`}", .con = DBI::ANSI())
}

truncate_sql <- function(schema, table_name){
truncate_sql <- function(schema, table_name) {
glue::glue_sql("TRUNCATE TABLE {`schema`}.{`table_name`}", .con = DBI::ANSI())
}

add_filter_sql <- function(connection, initial_sql, filter_stmt){
add_filter_sql <- function(connection, initial_sql, filter_stmt) {
filter_sql <- format_filter(connection, filter_stmt)
glue::glue(
initial_sql,
Expand All @@ -16,19 +16,19 @@ add_filter_sql <- function(connection, initial_sql, filter_stmt){
}

delete_table_rows <- function(database,
server,
schema,
table_name,
filter_stmt = NULL) {
if (is.null(filter_stmt)){
server,
schema,
table_name,
filter_stmt = NULL) {
if (is.null(filter_stmt)) {
sql <- truncate_sql(schema, table_name)
} else {
connection <- create_sqlserver_connection(
server = server,
database = database
)
initial_sql <- delete_sql(schema, table_name)
sql <- add_filter_sql(connection, initial_sql, filter_stmt)
connection <- create_sqlserver_connection(
server = server,
database = database
)
initial_sql <- delete_sql(schema, table_name)
sql <- add_filter_sql(connection, initial_sql, filter_stmt)
}
execute_sql(server, database, sql, output = FALSE)
}
3 changes: 1 addition & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ get_pk_name <- function(server,
# format filter used in read and delete table rows functions
format_filter <- function(connection, filter_stmt) {
sql <- dbplyr::translate_sql(!!rlang::parse_expr(filter_stmt),
con = connection
con = connection
)
sql <- as.character(sql)
}

0 comments on commit 8767a1e

Please sign in to comment.