| e_rows_update.tbl_dbi {editbl} | R Documentation | 
rows_update implementation for DBI backends.
Description
rows_update implementation for DBI backends.
Usage
## S3 method for class 'tbl_dbi'
e_rows_update(
  x,
  y,
  by = NULL,
  match = NULL,
  ...,
  copy = FALSE,
  in_place = FALSE
)
Arguments
| x,y | A pair of data frames or data frame extensions (e.g. a tibble).
 | 
| by | An unnamed character vector giving the key columns. The key columns
must exist in both  By default, we use the first column in  | 
| match | named  | 
| ... | Other parameters passed onto methods. | 
| copy | If  | 
| in_place | Should  When  | 
Details
Mainly a wrapper around rows_update.
Allows for specific implementations should the behavior differ from what's needed by editbl.
Reason for separate method is to avoid conflicts on package loading.
Value
An object of the same type as x. The order of the rows and columns of x
is preserved as much as possible. The output has the following properties:
-  rows_update()androws_patch()preserve the number of rows;rows_insert(),rows_append(), androws_upsert()return all existing rows and potentially new rows;rows_delete()returns a subset of the rows.
- Columns are not added, removed, or relocated, though the data may be updated. 
- Groups are taken from - x.
- Data frame attributes are taken from - x.
If in_place = TRUE, the result will be returned invisibly.
Author(s)
Jasper Schelfhout
Examples
library(dplyr)
# Set up a test table
conn <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
artists_df <- data.frame(
         ArtistId = c(1,2),
         Name = c("AC/DC", "The Offspring")
)
DBI::dbWriteTable(conn, "Artist", artists_df)     
# Update rows without changing the key.
artists <- tbl(conn, "Artist")
DBI::dbBegin(conn)
y <- data.frame(ArtistId = 1, Name = "DC/AC")
e_rows_update(
     x = artists,
     y = y,
     by = "ArtistId",
     in_place = TRUE)
DBI::dbRollback(conn)
# Update key values of rows.
DBI::dbBegin(conn)
y <- data.frame(ArtistId = 999, Name = "DC/AC")
match <- list(
   x = data.frame("ArtistId" = 1),
   y = data.frame("ArtistId" = 999)
)
e_rows_update(
    x = artists,
    y = y,
    match = match,
    by = "ArtistId",
    in_place = TRUE)
DBI::dbRollback(conn)
DBI::dbDisconnect(conn)