@@ -16,13 +16,74 @@ test_that("quoting SQL", {
1616 " Robert'); DROP TABLE Students;--" )
1717})
1818
19- test_that(" quoting Id" , {
19+ test_that(" quoting Id, table" , {
20+ con <- postgresDefault()
21+
22+ quoted <- dbQuoteIdentifier(con , Id(table = ' Students;--' ))
23+ expect_s4_class(quoted , ' SQL' )
24+ expect_equal(as.character(quoted ), ' "Students;--"' )
25+ })
26+
27+ test_that(" quoting Id, table, unnamed" , {
28+ con <- postgresDefault()
29+
30+ quoted <- dbQuoteIdentifier(con , Id(' Students;--' ))
31+ expect_s4_class(quoted , ' SQL' )
32+ expect_equal(as.character(quoted ), ' "Students;--"' )
33+ })
34+
35+ test_that(" quoting Id, schema" , {
36+ con <- postgresDefault()
37+
38+ quoted <- dbQuoteIdentifier(con , Id(schema = ' Robert' ))
39+ expect_s4_class(quoted , ' SQL' )
40+ expect_equal(as.character(quoted ), ' "Robert"' )
41+ })
42+
43+ test_that(" quoting Id, schema, unnamed" , {
44+ con <- postgresDefault()
45+
46+ quoted <- dbQuoteIdentifier(con , Id(' Robert' ))
47+ expect_s4_class(quoted , ' SQL' )
48+ expect_equal(as.character(quoted ), ' "Robert"' )
49+ })
50+
51+ test_that(" quoting Id, fully-qualified table" , {
2052 con <- postgresDefault()
2153
2254 quoted <- dbQuoteIdentifier(con , Id(schema = ' Robert' , table = ' Students;--' ))
2355 expect_s4_class(quoted , ' SQL' )
24- expect_equal(as.character(quoted ),
25- ' "Robert"."Students;--"' )
56+ expect_equal(as.character(quoted ), ' "Robert"."Students;--"' )
57+ })
58+
59+ test_that(" quoting Id, fully-qualified column, #263" , {
60+ con <- postgresDefault()
61+
62+ quoted <-
63+ dbQuoteIdentifier(
64+ con ,
65+ Id(schema = " Robert" , table = " Students;--" , column = " dormitory" )
66+ )
67+ expect_s4_class(quoted , ' SQL' )
68+ expect_equal(as.character(quoted ), ' "Robert"."Students;--"."dormitory"' )
69+ })
70+
71+ test_that(" quoting Id, column, unordered" , {
72+ con <- postgresDefault()
73+
74+ quoted <-
75+ dbQuoteIdentifier(con , Id(column = " dormitory" , table = ' Students;--' ))
76+ expect_s4_class(quoted , ' SQL' )
77+ expect_equal(as.character(quoted ), ' "Students;--"."dormitory"' )
78+ })
79+
80+ test_that(" quoting Id, fully-qualified column, unnamed" , {
81+ con <- postgresDefault()
82+
83+ quoted <-
84+ dbQuoteIdentifier(con , Id(' Robert' , ' Students;--' , " dormitory" ))
85+ expect_s4_class(quoted , ' SQL' )
86+ expect_equal(as.character(quoted ), ' "Robert"."Students;--"."dormitory"' )
2687})
2788
2889test_that(" unquoting identifier - SQL with quotes" , {
0 commit comments