Skip to content

Commit

Permalink
Bump default serialization version in use_data() to 3 (#2044)
Browse files Browse the repository at this point in the history
* Fixes #1966 - bumped default serialization version in use_data() to 3

* addition of bullet in NEWS.md to alert for update to use_data() version bump

* update param in use_data & related test for default version 3
  • Loading branch information
laurabrianna authored Aug 15, 2024
1 parent 00552db commit 4ce704b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# usethis (development version)

* `use_data()` now uses serialization version 3 by default. (@laurabrianna, #2044)
* Reverse dependency checks are only suggested if they exist
(#1817, @seankross).

Expand Down
8 changes: 4 additions & 4 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#' files. If you really want to do so, set this to `TRUE`.
#' @param compress Choose the type of compression used by [save()].
#' Should be one of "gzip", "bzip2", or "xz".
#' @param version The serialization format version to use. The default, 2, was
#' the default format from R 1.4.0 to 3.5.3. Version 3 became the default from
#' R 3.6.0 and can only be read by R versions 3.5.0 and higher.
#' @param version The serialization format version to use. The default, 3, can
#' only be read by R versions 3.5.0 and higher. For R 1.4.0 to 3.5.3, use
#' version 2.
#' @inheritParams base::save
#'
#' @seealso The [data chapter](https://r-pkgs.org/data.html) of [R
Expand All @@ -38,7 +38,7 @@ use_data <- function(...,
internal = FALSE,
overwrite = FALSE,
compress = "bzip2",
version = 2,
version = 3,
ascii = FALSE) {
check_is_package("use_data()")

Expand Down
8 changes: 4 additions & 4 deletions man/use_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ test_that("use_data() honors `overwrite` for internal data", {
expect_identical(letters2, rev(letters))
})

test_that("use_data() writes version 2 by default", {
test_that("use_data() writes version 3 by default", {
create_local_package()

x <- letters
use_data(x, internal = TRUE, version = 2, compress = FALSE)
use_data(x, internal = TRUE, compress = FALSE)
expect_identical(
rawToChar(readBin(proj_path("R", "sysdata.rda"), n = 4, what = "raw")),
"RDX2"
"RDX3"
)
})

Expand Down

0 comments on commit 4ce704b

Please sign in to comment.