From ea8af428e0869fe5f9671be4ef64e1f6811b3901 Mon Sep 17 00:00:00 2001 From: Elena Felder <41136058+elefeint@users.noreply.github.com> Date: Tue, 24 Dec 2024 10:59:33 -0500 Subject: [PATCH] add r-dbi user-agent --- src/database.cpp | 1 + tests/testthat/test-connect.R | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/database.cpp b/src/database.cpp index e26275628..c0bf1680c 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -29,6 +29,7 @@ static bool CastRstringToVarchar(Vector &source, Vector &result, idx_t count, Ca if (readonly) { config.options.access_mode = AccessMode::READ_ONLY; } + config.options.duckdb_api = "r-dbi"; auto confignames = configsexp.names(); diff --git a/tests/testthat/test-connect.R b/tests/testthat/test-connect.R index 80310063b..aae8cc4d9 100644 --- a/tests/testthat/test-connect.R +++ b/tests/testthat/test-connect.R @@ -184,3 +184,12 @@ test_that("config only applies to the first driver object for a path", { gc() }) +test_that("user agent is set to r", { + skip_if_not(TEST_RE2) + + drv <- duckdb() + con <- dbConnect(drv) + expect_match(dbGetQuery(con, "PRAGMA user_agent")[1, "user_agent"], "duckdb/.*(.*) r-dbi") + + gc() +}) \ No newline at end of file