Skip to content

'dbDataType' warning/message when using st_write on a database #2349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrew-plowright opened this issue Feb 25, 2024 · 1 comment
Closed

Comments

@andrew-plowright
Copy link

In issue #1693, @etiennebr discusses two ways to connect to a database: gdal and sf "native". In his example, the second "native" solution generates the following warning/message:

#> Note: method with signature 'DBIObject#sf' chosen for function 'dbDataType',
#>  target signature 'PqConnection#sf'.
#>  "PqConnection#ANY" would also be valid

I am also getting a similar warning/message when appending data to a blank Geopackage.

# Create blank geopackage
blank_sf <- sf::st_sf(geometry  = sf::st_sfc(crs = sf::st_crs(4326)))
sf::st_write(blank_sf, "my_gpkg.gpkg")

# Connect to Geopackage
con <- DBI::dbConnect(RSQLite::SQLite(), dbname =  "my_gpkg.gpkg")

# Create new_data
data <- sf::st_sf(
  geom = sf::st_as_sfc(
    list(sf::st_polygon(list( cbind(c(0,1,1,0,0), c(0,0,1,1,0))))),
    crs = sf::st_crs(4326)
  )
)

# Append new data to Geopackage
sf::st_write(obj = data, dsn = con, driver = "GPKG", append = TRUE)
Note: method with signature ‘DBIObject#sf’ chosen for function ‘dbDataType’,
 target signature ‘SQLiteConnection#sf’.
 "SQLiteConnection#ANY" would also be valid

This message seems to only appear once. Repeating the operation doesn't generate it again unless the session is restarted. Is there any way to suppress this message?

My namespace:

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

loaded via a namespace (and not attached):
 [1] vctrs_0.6.3        cli_3.6.1          rlang_1.1.1        DBI_1.1.3          KernSmooth_2.23-21 generics_0.1.3     sf_1.0-14          glue_1.6.2         bit_4.0.5          e1071_1.7-13       fansi_1.0.4       
[12] grid_4.3.1         classInt_0.4-9     tibble_3.2.1       fastmap_1.1.1      lifecycle_1.0.3    memoise_2.0.1      compiler_4.3.1     dplyr_1.1.2        RSQLite_2.3.1      blob_1.2.4         Rcpp_1.0.12       
[23] pkgconfig_2.0.3    rstudioapi_0.15.0  R6_2.5.1           class_7.3-22       tidyselect_1.2.0   utf8_1.2.3         pillar_1.9.0       magrittr_2.0.3     tools_4.3.1        proxy_0.4-27       bit64_4.0.5       
[34] units_0.8-2        cachem_1.0.8  
@etiennebr
Copy link
Member

Hi Andrew, thanks for reporting that issue. You are right, the note gets printed once per session. This notice comes from DBI, not sf. I don't plan to fix this short term, but for sure I'll keep it in mind when I touch that code again since you are not the only user that finds it confusing. 🙂

I'll close the issue, but if this notice creates issues that I've overlooked, please reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants