|
6 | 6 | #' The latter is copied to the former.
|
7 | 7 | #' The default is to create temporary tables, set `temporary = FALSE` to create permanent tables.
|
8 | 8 | #' 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. |
10 | 10 | #'
|
11 | 11 | #' @inheritParams dm_examine_constraints
|
12 | 12 | #'
|
13 | 13 | #' @param dest An object of class `"src"` or `"DBIConnection"`.
|
14 | 14 | #' @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. |
18 | 22 | #' @param temporary If `TRUE`, only temporary tables will be created.
|
19 | 23 | #' These tables will vanish when disconnecting from the database.
|
20 | 24 | #' @param schema Name of schema to copy the `dm` to.
|
21 | 25 | #' If `schema` is provided, an error will be thrown if `temporary = FALSE` or
|
22 | 26 | #' `table_names` is not `NULL`.
|
23 | 27 | #'
|
24 | 28 | #' 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`. |
28 | 61 | #'
|
29 | 62 | #' @family DB interaction functions
|
30 | 63 | #'
|
@@ -63,11 +96,7 @@ copy_dm_to <- function(
|
63 | 96 | progress = NA,
|
64 | 97 | unique_table_names = NULL,
|
65 | 98 | 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 | + # |
71 | 100 |
|
72 | 101 | if (!is.null(unique_table_names)) {
|
73 | 102 | deprecate_stop(
|
|
0 commit comments