tests/testthat/test_125_expr_field_def.R

testthat::context("ExprFieldDef class")

testthat::test_that("Initializer works fine", {
  testthat::expect_error(ExprFieldDef$new())
  testthat::expect_error(ExprFieldDef$new("a"))
  ExprFieldDef$new("a", "integer")
})

testthat::test_that("Conversion to string works fine", {
  testthat::expect_equal(ExprFieldDef$new("a", "integer")$toString(),
                         "a INTEGER")
  testthat::expect_equal(ExprFieldDef$new("a", "integer",
                                          primary = TRUE)$toString(),
                         "a INTEGER PRIMARY KEY")
  testthat::expect_equal(ExprFieldDef$new("a", "integer",
                                          nullable = FALSE)$toString(),
                         "a INTEGER NOT NULL")
})

Try the sqlq package in your browser

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

sqlq documentation built on Sept. 16, 2025, 9:10 a.m.