You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if i'm just oblivious to something here but the SQL generated by sql_query_upsert for an Oracle connection seems to have a bug in it. It's referencing a table called 'excluded' which doesn't seem to be invloved in anything. It also failed to wrap the ON clause in parenthesis which I think is required by oracle.
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
library(dbplyr)
#> #> Attaching package: 'dbplyr'#> The following objects are masked from 'package:dplyr':#> #> ident, sqldbplyr::sql_query_upsert( con= simulate_oracle(),
table= ident("t1"),
from= ident("t2"),
by= c("a"),
update_cols= c("b")
)
#> <SQL> MERGE INTO `t1`#> USING `t2` AS `...y`#> ON `...y`.`a` = `t1`.`a`#> WHEN MATCHED THEN#> UPDATE SET `b` = `excluded`.`b`#> WHEN NOT MATCHED THEN hi tim#> INSERT (`a`, `b`)#> VALUES (`...y`.`a`, `...y`.`b`)#> ;
with the above changes (updated lines commented out)
the reprex becomes:
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union
library(dbplyr)
#> #> Attaching package: 'dbplyr'#> The following objects are masked from 'package:dplyr':#> #> ident, sqldbplyr::sql_query_upsert( con= simulate_oracle(),
table= ident("t1"),
from= ident("t2"),
by= c("a"),
update_cols= c("b")
)
#> <SQL> MERGE INTO `t1`#> USING `t2` AS `...y`#> ON (`...y`.`a` = `t1`.`a`)#> WHEN MATCHED THEN#> UPDATE SET `b` = `t2`.`b`#> WHEN NOT MATCHED THEN#> INSERT (`a`, `b`)#> VALUES (`...y`.`a`, `...y`.`b`)#> ;
I'm not sure if i'm just oblivious to something here but the SQL generated by sql_query_upsert for an Oracle connection seems to have a bug in it. It's referencing a table called 'excluded' which doesn't seem to be invloved in anything. It also failed to wrap the ON clause in parenthesis which I think is required by oracle.
Created on 2023-05-22 with reprex v2.0.2
I've found that the following changes to the sql_query_upsert.Oracle function in backend-oracle.R resolve the issue:
with the above changes (updated lines commented out)
the reprex becomes:
Created on 2023-05-22 with reprex v2.0.2
I'd be interested to submit a PR if you feel its warrented.
Cheers,
Tim
The text was updated successfully, but these errors were encountered: