OHDSI / OHDSI/DatabaseConnector
existsTable does not work with createDbiConnectionDetails
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 57
- Forks
- 93
- Avg merge
- 10d 12h
- Merged PRs (30d)
- 1
Description
Unexpected result when running existsTable on connection created with createDbiConnectionDetails and supplying a databaseSchema. It does work when I provide it the '@dbiConnection':
connectionDetails <- DatabaseConnector::createDbiConnectionDetails(
dbms = "postgresql",
drv = RPostgres::Postgres(),
dbname = Sys.getenv("CDM5_POSTGRESQL_DBNAME"),
host = Sys.getenv("CDM5_POSTGRESQL_HOST"),
user = Sys.getenv("CDM5_POSTGRESQL_USER"),
password = Sys.getenv("CDM5_POSTGRESQL_PASSWORD")
)
connection <- DatabaseConnector::connect(connectionDetails)
DatabaseConnector::existsTable(connection, tableName = 'achilles_results', databaseSchema = 'results')
#> [1] FALSE
DatabaseConnector::existsTable(connection@dbiConnection, tableName = 'achilles_results', databaseSchema = 'results')
#> [1] TRUE
is(connection, "DatabaseConnectorConnection")
#> [1] TRUE
DatabaseConnector::disconnect(connection)
Created on 2026-02-20 with reprex v2.1.1
Relevant line in function. listTables for dbi connection returns tables in public schema:
https://github.com/OHDSI/DatabaseConnector/blob/68ef37d156daa729b9539d500aa4475a831e1a22/R/ListTables.R#L117-L119
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in R/ListTables.R at the linked lines 117-119 and trace how existsTable handles a DatabaseConnectorConnection from createDbiConnectionDetails versus its dbiConnection. Reproduce the PostgreSQL example with databaseSchema set to results, then verify that both connection forms return the same table-existence result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, r
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100