Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`glue_sql()` now collapses zero-length vector into `DBI::SQL("NULL")` #134

Merged
merged 1 commit into from Apr 15, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -3,6 +3,7 @@
## Features

* `glue()` now has a `+` method to combine strings.
* `glue_sql()` now collapses zero-length vector into `DBI::SQL("NULL")` (#134 @shrektan).

## Bugfixes and minor changes

@@ -144,6 +144,9 @@ sql_quote_transformer <- function(connection) {
if (should_collapse) {
res <- glue_collapse(res, ", ")
}
if (length(res) == 0L) {
res <- DBI::SQL("NULL")
}
res
}
}
@@ -48,6 +48,9 @@ describe("glue_sql", {
expect_identical(glue_sql("{var*}", .con = con, var = "a"), DBI::SQL("'a'"))
expect_identical(glue_sql("{var*}", .con = con, var = letters[1:5]), DBI::SQL("'a', 'b', 'c', 'd', 'e'"))
})
it('collapses values should return NULL for length zero vector', {
expect_identical(glue_sql("{var*}", .con = con, var = character()), DBI::SQL("NULL"))
})
it("should return an SQL NULL by default for missing values", {
var <- list(NA, NA_character_, NA_real_, NA_integer_)
expect_identical(glue_sql("x = {var}", .con = con), rep(DBI::SQL("x = NULL"), 4))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.