Repository navigation
docs: Show how to find tables in a non-default schema - #675
Conversation
Records the review of #583 on its PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
Resolved: How to proceed with #583?#583 documents the two existing ways to find tables in a non-default schema:
Kirill has the say. If nobody decides, #583 stays open and unanswered, and so does the contributor's CI question from October. Generated by Claude Code |
Resolved: What to tell the contributor on #583?Nothing has been posted on #583. Following the "how to proceed" decision, #583's two commits were cherry-picked into #675 with their authorship intact, and the findings were fixed in commits on top. Here is a draft for Kirill to post (or edit) on #583 once #675 merges: Thank you for picking up #399, and sorry for the slow reply! The content was accurate, so I took your two commits, with you as their author, into #675 and made a few changes on top:
- `-c search_path=myschema` replaces the search path, so the example now uses `myschema,public` to keep the tables in `public` visible.
- The full example now lives only in `?postgres-tables`, and `?Postgres` links to it. This also keeps the claim out of the `...` parameter that `?Redshift` inherits.
- The example quotes the schema with `dbQuoteIdentifier()`, creates a uniquely named schema, and removes only what it created.
- The roxygen uses semantic line breaks, and the test is shorter.
The `format-suggest` failure here was a problem in our workflow, and it has been fixed on `main` since. I'm closing this in favor of #675. Thanks again!
Kirill asked in chat (relayed): "Post everything that needs posting". Posted on #583 with "which is now merged" added, and #583 closed. Generated by Claude Code |
Resolved: Keep the new test from #583?The test at test-dbConnect.R L57-L102 passes, and it is self-contained. However, its
Kirill has the say. If nobody decides, the recommendation goes into the request to the contributor. Generated by Claude Code |
|
Take the contents to this PR and fix findings. |
…s the path Keeps the full example in `?postgres-tables` only and links to it from `?Postgres`. The `search_path` example keeps `public`, quotes the schema with `dbQuoteIdentifier()`, and the claim stays out of the `...` parameter that `?Redshift` inherits. The example creates a schema with a unique name and removes only what it created. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
Cleans up with `withr::defer()`, creates a uniquely named schema without a preceding `DROP`, and removes only what it created, so the test prints no server notices. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
…ic` form Says that `dbListTables()` skips `pg_catalog`, and covers `search_path=<schema>,public` in the test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
Accepted limitations
Generated by Claude Code |
…-dir Keep both the "Default host" section from this branch and the "Schemas" section from #675 in ?Postgres. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
Closes #399.
This PR documents the two existing ways to find tables in a schema other than
public. Its content comes from #583 byLeonidasZhak: their two commits are cherry-picked here with their authorship intact, and our own commits on top fix the findings of the review of #583. Kirill asked for this: "Take the contents to this PR and fix findings."Changes
?postgres-tables, section "Schemas, catalogs, tablespaces" (R/tables.R):dbListObjects(conn, Id(schema = ))for listing the tables in one schema, and todbExistsTable(conn, Id(schema = , table = ))for checking a single table.dbListTables()lists the tables in all schemas on the search path exceptpg_catalog, temporary tables included.options = "-c search_path=my_schema,public"indbConnect(). It also says that this replaces the default path, that a schema that does not exist is skipped silently, and how to quote a schema name.options, such as some connection poolers, it namesSET search_pathas the alternative.?postgres-tablesexample gains the only full walk-through. It creates a schema with a unique name (basename(tempfile())), quotes it withdbQuoteIdentifier(), lists the schema's tables both ways, and removes only the table and schema it created, with noCASCADE.?Postgresgains a short "Schemas" section that links to?postgres-tables. ItsdbConnect()example and its...parameter are unchanged frommain, so?Redshift, which inherits..., makes no claim aboutoptionson Redshift.tests/testthat/test-dbConnect.Rgets one test. It checksdbListObjects()with a schema prefix anddbListTables()on connections withsearch_path=<schema>andsearch_path=<schema>,public. Cleanup useswithr::defer(), and the test prints no server notices.Review findings on #583 and how they were addressed
public, and the docs say so.?Postgreslinks to it....text, andoptionsis described as rejected by some servers, such as connection poolers.paste0()with a raw schema name: the example now usesdbQuoteIdentifier(), and the docs explain how to escape spaces.DROP SCHEMA ... CASCADEon a fixed name: the example now uses a unique name and drops only what it created.Checks
Run locally against PostgreSQL 16:
devtools::document()(the Rd files are in sync, andman/Redshift.Rdis identical tomain),air format, and bothexample("postgres-tables")andexample("Postgres"). Both examples run cleanly and leave no schema behind.devtools::test(filter = "dbConnect")gives 13 passed and 0 failed. A clean review found nothing above Low, and its Lows are applied. Quoting was checked by hand: a schema namedMy Schemaworks withoptions = "-c search_path=\"My\\ Schema\",public", and so doesSET search_path. A fullR CMD checkhas not been run, and nothing was verified against Redshift. See Accepted limitations.Open question: what to tell the contributor on #583. Resolved: how to proceed, keep the test.
https://claude.ai/code/session_01Hr1rd6e5NcxC9GSrNJDokc
Generated by Claude Code