Skip to content

Commit 2164518

Browse files
committed
Tweak docs
1 parent a131af7 commit 2164518

File tree

2 files changed

+81
-20
lines changed

2 files changed

+81
-20
lines changed

R/db-interface.R

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,58 @@
66
#' The latter is copied to the former.
77
#' The default is to create temporary tables, set `temporary = FALSE` to create permanent tables.
88
#' Unless `set_key_constraints` is `FALSE`, primary key, foreign key, and unique constraints
9-
#' are set on all databases.
9+
#' are set, and indexes for foreign keys are created, on all databases.
1010
#'
1111
#' @inheritParams dm_examine_constraints
1212
#'
1313
#' @param dest An object of class `"src"` or `"DBIConnection"`.
1414
#' @param dm A `dm` object.
15-
#' @param set_key_constraints If `TRUE` will mirror `dm` primary and foreign key constraints on a database
16-
#' and create indexes for foreign key constraints.
17-
#' Set to `FALSE` if your data model currently does not satisfy primary or foreign key constraints.
15+
#' @inheritParams rlang::args_dots_empty
16+
#' @param set_key_constraints If `TRUE` will mirror
17+
#' the primary, foreign, and unique key constraints
18+
#' and create indexes for foreign key constraints
19+
#' for the primary and foreign keys in the `dm` object.
20+
#' Set to `FALSE` if your data model currently does not satisfy
21+
#' primary or foreign key constraints.
1822
#' @param temporary If `TRUE`, only temporary tables will be created.
1923
#' These tables will vanish when disconnecting from the database.
2024
#' @param schema Name of schema to copy the `dm` to.
2125
#' If `schema` is provided, an error will be thrown if `temporary = FALSE` or
2226
#' `table_names` is not `NULL`.
2327
#'
2428
#' Not all DBMS are supported.
25-
#' @inheritParams dm_sql
26-
#' @inheritParams rlang::args_dots_empty
27-
#' @param unique_table_names,copy_to Deprecated.
29+
#' @param table_names Desired names for the tables on `dest`; the names within the `dm` remain unchanged.
30+
#' Can be `NULL`, a named character vector, or a vector of [DBI::Id] objects.
31+
#'
32+
#' If left `NULL` (default), the names will be determined automatically depending on the `temporary` argument:
33+
#'
34+
#' 1. `temporary = TRUE` (default): unique table names based on the names of the tables in the `dm` are created.
35+
#' 1. `temporary = FALSE`: the table names in the `dm` are used as names for the tables on `dest`.
36+
#'
37+
#' If a function or one-sided formula, `table_names` is converted to a function
38+
#' using [rlang::as_function()].
39+
#' This function is called with the unquoted table names of the `dm` object
40+
#' as the only argument.
41+
#' The output of this function is processed by [DBI::dbQuoteIdentifier()],
42+
#' that result should be a vector of identifiers of the same length
43+
#' as the original table names.
44+
#'
45+
#' Use a variant of
46+
#' `table_names = ~ DBI::SQL(paste0("schema_name", ".", .x))`
47+
#' to specify the same schema for all tables.
48+
#' Use `table_names = identity` with `temporary = TRUE`
49+
#' to avoid giving temporary tables unique names.
50+
#'
51+
#' If a named character vector,
52+
#' the names of this vector need to correspond to the table names in the `dm`,
53+
#' and its values are the desired names on `dest`.
54+
#' The value is processed by [DBI::dbQuoteIdentifier()],
55+
#' that result should be a vector of identifiers of the same length
56+
#' as the original table names.
57+
#'
58+
#' Use qualified names corresponding to your database's syntax
59+
#' to specify e.g. database and schema for your tables.
60+
#' @param unique_table_names,copy_to Must be `NULL`.
2861
#'
2962
#' @family DB interaction functions
3063
#'
@@ -63,11 +96,7 @@ copy_dm_to <- function(
6396
progress = NA,
6497
unique_table_names = NULL,
6598
copy_to = NULL) {
66-
# for the time being, we will be focusing on MSSQL
67-
# we want to
68-
# 1. change `dm_get_src_impl(dm)` to `dest`
69-
# 2. copy the tables to `dest`
70-
# 3. implement the key situation within our `dm` on the DB
99+
#
71100

72101
if (!is.null(unique_table_names)) {
73102
deprecate_stop(

man/copy_dm_to.Rd

Lines changed: 40 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)