tests/testthat/test_340_stmt_create.R

testthat::context("Statement Create class")

testthat::test_that("We can generate a simple CREATE statement", {
  fields_def <- list(ExprFieldDef$new('id', 'integer', primary=TRUE),
                     ExprFieldDef$new('title', 'varchar(200)', nullable=FALSE),
                     ExprFieldDef$new('author', 'varchar(80)'))
  x <- StmtCreate$new(tabl = 'books', fields_def = fields_def)
  testthat::expect_equal(x$toString(),
                         paste("CREATE TABLE books",
                               "(id INTEGER PRIMARY KEY,",
                               '"title" VARCHAR(200) NOT NULL,',
                               "author VARCHAR(80))"))
})

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.