File: test-table-insert.R

package info (click to toggle)
dbi 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,740 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
test_that("appending with zero columns throws a dedicated error (#313)", {
  skip_if_not_installed("RSQLite")

  db <- dbConnect(RSQLite::SQLite(), ":memory:")
  on.exit(dbDisconnect(db))

  dbExecute(db, "create table T(n integer primary key)")
  expect_error(dbAppendTable(db, "T", data.frame()), "column")
})

test_that("appending with zero columns throws a dedicated error (#336)", {
  skip_if_not_installed("RSQLite")

  library(RSQLite)
  a <- data.frame(sep = c(1, 2, 3))
  con <- dbConnect(SQLite())
  on.exit(dbDisconnect(con))

  dbWriteTable(con, "a", a)
  expect_equal(dbReadTable(con, "a"), a)
})

test_that("appending with Id works (#380)", {
  skip_if_not_installed("RSQLite")

  db <- dbConnect(RSQLite::SQLite(), ":memory:")
  on.exit(dbDisconnect(db))

  dbExecute(db, "create table T(n integer primary key)")
  expect_equal(dbAppendTable(db, Id(table = "T"), data.frame(n = 1:10)), 10)
})