Skip to content

existsTable does not work with createDbiConnectionDetails #327

Description

@MaximMoinat

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:

} else if (is(connection, "DatabaseConnectorConnection")) {
tableNames <- DBI::dbListTables(conn = connection, databaseSchema = databaseSchema)
} else if (is(connection, "PqConnection") || is(connection, "RedshiftConnection") || is(connection, "duckdb_connection")) {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions