Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# dbplyr (development version)

* SQL Server uses `DATEDIFF_BIG` instead of `DATEDIFF` to work regardless of data size (@edward-burn, #1666).
* `na_matches = "na"` now works correctly with inequality and overlap joins, preserving the comparison operator instead of converting to equality (#1505).
* `copy_inline()` now works with blob columns (#1515).
* `tbl_sql()` is now (soft) deprecated. It hasn't been required in a while.
Expand Down
6 changes: 3 additions & 3 deletions R/backend-mssql.R
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ simulate_mssql <- function(version = "15.0") {
check_dots_empty()
check_unsupported_arg(precision, allowed = "day")
check_unsupported_arg(n, allowed = 1L)

sql_glue("DATEDIFF(DAY, {start}, {end})")
# https://learn.microsoft.com/en-us/sql/t-sql/functions/datediff-big-transact-sql?view=sql-server-ver17
sql_glue("DATEDIFF_BIG(DAY, {start}, {end})")
},

difftime = function(time1, time2, tz, units = "days") {
check_unsupported_arg(tz)
check_unsupported_arg(units, allowed = "days")

sql_glue("DATEDIFF(DAY, {time2}, {time1})")
sql_glue("DATEDIFF_BIG(DAY, {time2}, {time1})")
}
)

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-backend-mssql.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ test_that("custom clock functions translated correctly", {
expect_translation(
con,
date_count_between(date_column_1, date_column_2, "day"),
"DATEDIFF(DAY, `date_column_1`, `date_column_2`)"
"DATEDIFF_BIG(DAY, `date_column_1`, `date_column_2`)"
)
expect_snapshot(
error = TRUE,
Expand Down Expand Up @@ -217,12 +217,12 @@ test_that("difftime is translated correctly", {
expect_translation(
con,
difftime(start_date, end_date, units = "days"),
"DATEDIFF(DAY, `end_date`, `start_date`)"
"DATEDIFF_BIG(DAY, `end_date`, `start_date`)"
)
expect_translation(
con,
difftime(start_date, end_date),
"DATEDIFF(DAY, `end_date`, `start_date`)"
"DATEDIFF_BIG(DAY, `end_date`, `start_date`)"
)

expect_snapshot(
Expand Down
Loading