OHDSI / OHDSI/DatabaseConnector

existsTable does not work with createDbiConnectionDetails

Open
#327 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.