File: make.db.names.Rd

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 (107 lines) | stat: -rw-r--r-- 3,528 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R, R/isSQLKeyword.R,
%   R/make.db.names.R
\name{make.db.names.default}
\alias{make.db.names.default}
\alias{isSQLKeyword.default}
\alias{isSQLKeyword}
\alias{make.db.names}
\alias{SQLKeywords}
\title{Make R identifiers into legal SQL identifiers}
\usage{
make.db.names.default(
  snames,
  keywords = .SQL92Keywords,
  unique = TRUE,
  allow.keywords = TRUE
)

isSQLKeyword.default(
  name,
  keywords = .SQL92Keywords,
  case = c("lower", "upper", "any")[3]
)

isSQLKeyword(
  dbObj,
  name,
  keywords = .SQL92Keywords,
  case = c("lower", "upper", "any")[3],
  ...
)

make.db.names(
  dbObj,
  snames,
  keywords = .SQL92Keywords,
  unique = TRUE,
  allow.keywords = TRUE,
  ...
)
}
\arguments{
\item{snames}{a character vector of R identifiers (symbols) from which we
need to make SQL identifiers.}

\item{keywords}{a character vector with SQL keywords, by default it's
\code{.SQL92Keywords} defined by the DBI.}

\item{unique}{logical describing whether the resulting set of SQL names
should be unique.  Its default is \code{TRUE}.  Following the SQL 92
standard, uniqueness of SQL identifiers is determined regardless of whether
letters are upper or lower case.}

\item{allow.keywords}{logical describing whether SQL keywords should be
allowed in the resulting set of SQL names.  Its default is \code{TRUE}}

\item{name}{a character vector with database identifier candidates we need
to determine whether they are legal SQL identifiers or not.}

\item{case}{a character string specifying whether to make the comparison as
lower case, upper case, or any of the two.  it defaults to \code{any}.}

\item{dbObj}{any DBI object (e.g., \code{DBIDriver}).}

\item{\dots}{any other argument are passed to the driver implementation.}
}
\value{
\code{make.db.names} returns a character vector of legal SQL
identifiers corresponding to its \code{snames} argument.

\code{SQLKeywords} returns a character vector of all known keywords for the
database-engine associated with \code{dbObj}.

\code{isSQLKeyword} returns a logical vector parallel to \code{name}.
}
\description{
These methods are DEPRECATED. Please use \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}
(or possibly \code{\link[=dbQuoteString]{dbQuoteString()}}) instead.
}
\details{
The algorithm in \code{make.db.names} first invokes \code{make.names} and
then replaces each occurrence of a dot \code{.} by an underscore \verb{_}.  If
\code{allow.keywords} is \code{FALSE} and identifiers collide with SQL
keywords, a small integer is appended to the identifier in the form of
\code{"_n"}.

The set of SQL keywords is stored in the character vector
\code{.SQL92Keywords} and reflects the SQL ANSI/ISO standard as documented
in "X/Open SQL and RDA", 1994, ISBN 1-872630-68-8.  Users can easily
override or update this vector.
}
\section{Bugs}{

The current mapping is not guaranteed to be fully reversible: some SQL
identifiers that get mapped into R identifiers with \code{make.names} and
then back to SQL with \code{\link[=make.db.names]{make.db.names()}} will not be equal to the
original SQL identifiers (e.g., compound SQL identifiers of the form
\code{username.tablename} will loose the dot ``.'').
}

\references{
The set of SQL keywords is stored in the character vector
\code{.SQL92Keywords} and reflects the SQL ANSI/ISO standard as documented
in "X/Open SQL and RDA", 1994, ISBN 1-872630-68-8.  Users can easily
override or update this vector.
}
\keyword{internal}