tests/testthat/test-data.table-set-functions.R

for (n in names(chinook_connections)) {
  conn <- chinook_connections[[n]]

  test_that(paste0("setcolorder works", " [", n, "]"), {
    expect_no_error(Album <- dbi.table(conn, DBI::Id("Album")))
    expect_no_error(Artist <- dbi.table(conn, DBI::Id("Artist")))

    expect_true(reference.test({
      x <- merge(Album, Artist, by = "ArtistId")
      setcolorder(x, c(4, 2, 3, 1))
    }))

    expect_true(reference.test({
      setcolorder(Artist, 2:1)
    }))

    expect_true(reference.test({
      setcolorder(Album, c("AlbumId", "ArtistId", "Title"))
    }))
  })
}

Try the dbi.table package in your browser

Any scripts or data that you put into this service are public.

dbi.table documentation built on June 29, 2025, 1:07 a.m.