Skip to content

Commit

Permalink
Auto-update from GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aviator-app[bot] committed Apr 1, 2024
1 parent a2c22b1 commit 2c26a48
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/testthat/test-dbQuoteIdentifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_that("quoting string", {
quoted <- dbQuoteIdentifier(con, "Robert'); DROP TABLE Students;--")
expect_s4_class(quoted, 'SQL')
expect_equal(as.character(quoted),
"`Robert'); DROP TABLE Students;--`")
"`Robert'); DROP TABLE Students;--`")
})

test_that("quoting SQL", {
Expand All @@ -15,7 +15,7 @@ test_that("quoting SQL", {
quoted <- dbQuoteIdentifier(con, SQL("Robert'); DROP TABLE Students;--"))
expect_s4_class(quoted, 'SQL')
expect_equal(as.character(quoted),
"Robert'); DROP TABLE Students;--")
"Robert'); DROP TABLE Students;--")
})

test_that("quoting Id", {
Expand All @@ -25,7 +25,7 @@ test_that("quoting Id", {
quoted <- dbQuoteIdentifier(con, Id(schema = 'Robert', table = 'Students;--'))
expect_s4_class(quoted, 'SQL')
expect_equal(as.character(quoted),
"`Robert`.`Students;--`")
"`Robert`.`Students;--`")
})

test_that("quoting Id with column, #254", {
Expand All @@ -35,7 +35,7 @@ test_that("quoting Id with column, #254", {
quoted <- dbQuoteIdentifier(con, Id(schema = 'Robert', table = 'Students;--', column = "dormitory"))
expect_s4_class(quoted, 'SQL')
expect_equal(as.character(quoted),
"`Robert`.`Students;--`.`dormitory`")
"`Robert`.`Students;--`.`dormitory`")
})

test_that("quoting Id with column, unordered", {
Expand All @@ -45,7 +45,7 @@ test_that("quoting Id with column, unordered", {
quoted <- dbQuoteIdentifier(con, Id(column = "dormitory", table = 'Students;--'))
expect_s4_class(quoted, 'SQL')
expect_equal(as.character(quoted),
"`Students;--`.`dormitory`")
"`Students;--`.`dormitory`")
})

test_that("quoting errors", {
Expand All @@ -60,40 +60,40 @@ test_that("unquoting identifier - SQL with quotes", {
on.exit(dbDisconnect(con))

expect_equal(dbUnquoteIdentifier(con, SQL('`Students;--`')),
list(Id(table = 'Students;--')))
list(Id(table = 'Students;--')))

expect_equal(dbUnquoteIdentifier(con, SQL('`Robert`.`Students;--`')),
list(Id(schema = 'Robert', table = 'Students;--')))
list(Id(schema = 'Robert', table = 'Students;--')))

expect_equal(dbUnquoteIdentifier(con, SQL('`Rob``ert`.`Students;--`')),
list(Id(schema = 'Rob`ert', table = 'Students;--')))
list(Id(schema = 'Rob`ert', table = 'Students;--')))

expect_equal(dbUnquoteIdentifier(con, SQL('`Rob.ert`.`Students;--`')),
list(Id(schema = 'Rob.ert', table = 'Students;--')))
list(Id(schema = 'Rob.ert', table = 'Students;--')))

expect_error(dbUnquoteIdentifier(con, SQL('`Robert.`Students`')),
"^Can't unquote")
"^Can't unquote")
})

test_that("unquoting identifier - SQL without quotes", {
con <- mariadbDefault()
on.exit(dbDisconnect(con))

expect_equal(dbUnquoteIdentifier(con, SQL('Students')),
list(Id(table = 'Students')))
list(Id(table = 'Students')))

expect_equal(dbUnquoteIdentifier(con, SQL('Robert.Students')),
list(Id(schema = 'Robert', table = 'Students')))
list(Id(schema = 'Robert', table = 'Students')))

expect_error(dbUnquoteIdentifier(con, SQL('Rob``ert.Students')),
"^Can't unquote")
"^Can't unquote")
})

test_that("unquoting identifier - Id", {
con <- mariadbDefault()
on.exit(dbDisconnect(con))

expect_equal(dbUnquoteIdentifier(con,
Id(schema = 'Robert', table = 'Students;--')),
list(Id(schema = 'Robert', table = 'Students;--')))
Id(schema = 'Robert', table = 'Students;--')),
list(Id(schema = 'Robert', table = 'Students;--')))
})

0 comments on commit 2c26a48

Please sign in to comment.