Cidree / rpostgis

rpostgis: R Interface to a 'PostGIS' Database
http://cidree.github.io/rpostgis/
77 stars 14 forks source link

dbSchema() returns NULL instead of FALSE when schema does not exist in database #29

Closed mac471 closed 1 year ago

mac471 commented 1 year ago

I am using dbSchema() to check for the existence of a schema name before attempting to pgInsert() to it. The documentation says that dbSchema() will return FALSE if the schema does not exist but it is returning NULL instead. I am running PostgreSQL 15 on a iMac (late 2015) that is running macOS Monterey. The client end is calling dbSchema() from a MacBook Pro running R 3.5.1 and rpostgis version 1.4.3.

basille commented 1 year ago

Thanks for the report! As a matter of fact, the documentation says that dbSchema returns TRUE if the schema exists (whether it already existed, or was just successfully created), but does not specify what happens if the schema does not exists and is not created (i.e. with exec = FALSE). In this case, the DB returns NULL and rpostgis just transfers the answer. To be honest, not sure there's a need to do anything about it.

Or maybe I'm missing something about what you're trying to achieve. If that is the case, please elaborate and provide functional code (reproducible might be difficult because of the DB connection).

(also please read #28 about the future of rpostgis)