Skip to content

feat: Deprecate setting the row.names default via pkgconfig, and move pkgconfig to Suggests - #805

Merged
krlmlr merged 6 commits into
mainfrom
claude/pkgconfig-usage-retirement-s673v3
Nov 13, 2026
Merged

krlmlr merged 6 commits into
mainfrom
claude/pkgconfig-usage-retirement-s673v3

Conversation

@krlmlr

@krlmlr krlmlr commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

RSQLite 2.0 changed the default of row.names to FALSE (#210) and offered pkgconfig::set_config("RSQLite::row.names.query" = NA) (and "RSQLite::row.names.table") as a temporary, per-package way to restore the old default. This PR starts retiring that setting, and with it the hard dependency on pkgconfig.

Changes

  • The row.names arguments of dbFetch(), dbReadTable(), dbWriteTable(), sqlData(), and sqliteBuildTableDefinition() now default to a plain FALSE. The man pages show that instead of the pkgconfig::get_config(...) expression.
  • If row.names is not passed, the new internal row_names_default() (in R/pkgconfig.R, replacing the pkgconfig_dummy() stub) consults pkgconfig, but only if its namespace is already loaded. Anyone who called pkgconfig::set_config() has it loaded, so nothing is loaded otherwise. The per-calling-package lookup works as before.
  • A value found there is still honored, with a deprecation warning once per key and value. The warning says the setting may come from a package in use, and asks to remove the pkgconfig::set_config() call and pass row.names explicitly. An explicit row.names argument always wins. The row.names documentation of dbReadTable() and dbWriteTable() says the same.
  • Internal metadata queries (dbListTables(), dbExistsTable(), and the schema lookup behind them) now pass row.names = FALSE. Before, they read the setting too, so the deprecation warning fired even when all user-facing calls were explicit, and a value of TRUE made them fail with "Column row_names not present in output" (also on main).
  • pkgconfig moves from Imports to Suggests. No other hard dependency of RSQLite pulls it in, so it drops out of the install tree.
  • The documented default for row.names in sqliteBuildTableDefinition() is corrected from TRUE to FALSE.
  • New tests in tests/testthat/test-row-names-default.R cover the plain default, the warn-and-honor path for both keys, the per-package lookup (a setting registered for another package applies only to calls from that package), and the internal queries. They use expect_no_warning(), so the testthat requirement is now 3.1.5.

Review

A clean-context review found no High or Medium issues; its Low findings are fixed or listed under Accepted limitations.

Follow-up

Removing the setting entirely after this is released is tracked in #803.

Checks

The new tests pass, and the new internal-query test fails without the fix. The full local test suite has errors only in test-httpvfs.R ("unable to open database file" when connecting to a local HTTP server) and in the callr test of test-dbConnect.R (no installed RSQLite in the subprocess); origin/main fails the test-httpvfs.R tests the same way in the same container, so they are unrelated to this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JK3J4sR7quzzvDCcL6ePB7

…ve pkgconfig to Suggests

The `row.names` arguments of `dbFetch()`, `dbReadTable()`, `dbWriteTable()`, `sqlData()`, and `sqliteBuildTableDefinition()` now default to a plain `FALSE`.
A default set with `pkgconfig::set_config("RSQLite::row.names.query" = ...)` or `"RSQLite::row.names.table"` is still honored,
but only if pkgconfig is already loaded, and it warns once per session.
Pass `row.names` explicitly instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JK3J4sR7quzzvDCcL6ePB7
…names` default

`dbListTables()`, `dbExistsTable()`, and the schema lookup behind them fetched without `row.names`,
so a default set via `pkgconfig::set_config("RSQLite::row.names.query" = ...)` triggered the deprecation warning
even when every user-facing call passed `row.names` explicitly,
and a value of `TRUE` made them fail with "Column row_names not present in output".
They now pass `row.names = FALSE`.

The warning now says the setting may come from a package in use and that the `pkgconfig::set_config()` call should be removed.
New tests cover the per-package lookup and the internal queries.
The documented default for `row.names` in `sqliteBuildTableDefinition()` is corrected to `FALSE`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JK3J4sR7quzzvDCcL6ePB7

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Review of this PR at a51ef38, by a Claude Code reviewer with clean context that read the PR description and the full diff against main, built both main and the head into separate libraries, ran the test suite and a set of targeted scripts (including two throwaway packages, one of which calls pkgconfig::set_config() in its .onLoad()), and posted nothing itself. Line numbers refer to that commit. "Confirmed" means reproduced by running code. There are no High or Medium findings: the change does what the description says, and the items below are small.

Low

1. The tests use expect_no_warning(), which needs a newer testthat than DESCRIPTION declares. By reading. tests/testthat/test-row-names-default.R:38 (and lines 57, 83, 98-104) are the first uses of expect_no_warning() in the test suite, and that expectation arrived in testthat 3.1.5, while DESCRIPTION:59 still says testthat (>= 3.0.0). Suggested fix: bump the requirement to testthat (>= 3.1.5).

2. One expect_no_warning() cannot fail, because the warning it guards against is already memoised. By reading, with the memoisation confirmed by running. In tests/testthat/test-row-names-default.R:83, the call from outside the tools namespace is checked for "no warning", but the identical message (same key, same value NA) was already emitted at line 80, and warning_once() is memoised on the message text, so a second emission is suppressed whether or not the lookup leaks. The expect_named() on line 84 is what actually proves the setting is not applied, so the test is still meaningful. Suggested fix: add memoise::forget(warning_once) before line 83, or drop the expect_no_warning() wrapper there.

3. The tests never exercise the two paths most users are on: a setting made from the global environment, and a session where pkgconfig is not loaded. Confirmed for the first half: under testthat::test_local() a pkgconfig::set_config() call inside test_that() registers the value for "RSQLite" (the test environment's top-level environment is the package namespace), not for R_GlobalEnv, so tests at lines 26, 49 and 94 cover "RSQLite set it for itself". Both untested paths do work when run by hand (see below). Suggested fix: optional; a callr::r() test (callr is already in Suggests) that uses RSQLite and asserts !isNamespaceLoaded("pkgconfig"), and one that calls pkgconfig::set_config() at top level, would pin both down.

4. "Once per session" is really once per distinct key and value, and the warning does not say which package made the setting. Confirmed. R/pkgconfig.R:14-18 builds the message from key and deparse(value), and warning_once() memoises on that text, so setting both keys gives two warnings (which seems right), while two packages setting the same value give one warning that names neither. The message says "in your code or in a package you use", which is honest, but an end user whose dependency sets it has no way to find the culprit. Suggested fix: optional; either accept it, or name the package in the message (pkgconfig only exposes that through the unexported get_from_session(), so this may not be worth it before the setting is removed in #803).

5. The deprecation is not documented anywhere a user would look it up. By reading. The man pages now show a plain row.names = FALSE and match the code (roxygen2::roxygenise() produces no diff), but the row.names parameter docs do not mention that a pkgconfig setting is still honored with a warning; the only description of the mechanism left is the RSQLite 2.0 entry at NEWS.md:794. NEWS.md is maintained by fledge, so the new entry will come from the PR title, which is adequate. Suggested fix: optional; one sentence in the row.names docs of dbReadTable() / dbWriteTable().

Checked and found sound

  • Every path that read the setting on main still honors it, with identical results. Confirmed by running the same script against main and against the head, with a package whose .onLoad() sets both keys to NA: dbGetQuery(), dbFetch(), dbReadTable() and dbWriteTable() called from that package give the same columns and row names on both builds, and the head adds the deprecation warning, once per key. sqlData() and sqliteBuildTableDefinition() were checked the same way with a setting made from the global environment.
  • An explicit row.names always wins, including row.names = NULL and row.names = FALSE, with no warning. Confirmed. missing(row.names) behaves correctly in all five methods, including sqlData(), whose generic already has a row.names formal.
  • The per-calling-package lookup is unchanged by the new helper. Confirmed: pkgconfig::get_config() walks all of sys.frames() and picks the innermost namespace that registered the key, so the extra row_names_default() frame (R/pkgconfig.R:4) only adds another RSQLite frame. A setting made by package A applies to A's calls and to calls A makes through package B, and not to B's own calls or to calls from the global environment, exactly as on main.
  • Nothing loads pkgconfig any more. Confirmed in a fresh session: after dbWriteTable(), dbGetQuery(), dbReadTable(), dbListTables(), dbExistsTable(), sqlData() and dbAppendTable(), isNamespaceLoaded("pkgconfig") is FALSE on the head and TRUE on main. The only remaining pkgconfig:: call in R/ is R/pkgconfig.R:9, behind the isNamespaceLoaded() guard on line 5, so it cannot fail when pkgconfig is not installed. No recursive hard dependency of RSQLite pulls pkgconfig in (checked with tools::package_dependencies() against CRAN).
  • Internal callers are insulated. Confirmed with "RSQLite::row.names.query" = TRUE set globally: dbListTables(), dbExistsTable() (character and Id with schema), dbListObjects(), dbListFields(), dbRemoveTable(), sqliteQuickColumn(), and the dbExistsTable() calls inside both dbWriteTable() methods all work without a warning, where main fails with "Column row_names not present in output". The only remaining call without an explicit row.names is in the deprecated dbGetPreparedQuery() (R/dbGetPreparedQuery_SQLiteConnection_character_data.frame.R:17), which returns a user-facing result and so reasonably keeps following the setting.
  • Tests: tests/testthat/test-row-names-default.R passes. The full suite has 775 passing expectations and no failures; the one error (test-dbConnect.R:159, a callr subprocess that cannot find an installed RSQLite) and the warnings (unavailable zh_TW.UTF-8 locale, httpvfs) are environmental and unrelated to this diff.

Generated by Claude Code

The new row.names tests use `expect_no_warning()`, which was added in testthat 3.1.5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The warning was already emitted and memoised just before, so `expect_no_warning()` could not fail.
Forgetting it first makes the expectation meaningful.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The `row.names` parameter of `dbReadTable()` and `dbWriteTable()` now says that a default set with `pkgconfig::set_config()` is still honored with a deprecation warning.
It also says that `row.names` should be passed explicitly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

Findings 1, 2 and 5 of the review above are fixed in 950091b, 68a709a and b150b75. These two remain:

  • tests/testthat/test-row-names-default.R: no test covers a pkgconfig::set_config() call made at top level, or a session in which pkgconfig is not loaded. A callr subprocess would load whichever RSQLite is installed instead of the code under test, so such a test would pass or fail for the wrong reason under test_local(). Both paths were confirmed by hand in the review. Relevance: low; reviewer's confidence that both paths work: high.
  • R/pkgconfig.R: the deprecation warning is shown once per key and value, and does not name the package that made the setting. pkgconfig exposes the caller only through an unexported function, and the setting goes away with Remove the deprecated pkgconfig setting for the row.names default #803. Relevance: low; reviewer's confidence: high.

Generated by Claude Code

@krlmlr
krlmlr merged commit 3f746a0 into main Nov 13, 2026
6 of 8 checks passed
@krlmlr
krlmlr deleted the claude/pkgconfig-usage-retirement-s673v3 branch November 13, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants