From 92b2bd1dd5d67c1d0a9cd77fd7154f90d4d243f9 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 10:38:19 +0100 Subject: [PATCH 01/36] test: Getting more info --- tests/testthat/test-getTableSignature.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index f5859a07..66e5dfba 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -284,8 +284,10 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { + tt <- getTableSignature(dplyr::copy_to(conn, data_random), conn) + print(tt) expect_identical( - getTableSignature(dplyr::copy_to(conn, data_random), conn), + tt, c( "Date" = "DATE", "POSIXct" = "DATETIME", From 8ca9590168b5e4160932f8b986a3fa4b83bdb8b4 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 10:54:59 +0100 Subject: [PATCH 02/36] test: again --- tests/testthat/test-getTableSignature.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 66e5dfba..73e5200c 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -283,9 +283,10 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { - test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { + print(conn) tt <- getTableSignature(dplyr::copy_to(conn, data_random), conn) print(tt) + test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { expect_identical( tt, c( From 79880712183ff4bc66804370ea5e48a6da944167 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 11:08:54 +0100 Subject: [PATCH 03/36] test: 3 --- tests/testthat/test-getTableSignature.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 73e5200c..317209d6 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -283,9 +283,13 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { - print(conn) - tt <- getTableSignature(dplyr::copy_to(conn, data_random), conn) - print(tt) + print(conn) + data_random2 <- data_random + dr_copy <- dplyr::copy_to(conn, data_random2) + print(dr_copy) + print(conn) + tt <- getTableSignature(dr_copy, conn) + print(tt) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { expect_identical( tt, From 4531b9db85d96e5035b66e65d5c74a4691903c3a Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 11:17:25 +0100 Subject: [PATCH 04/36] test: Only testing the one --- .github/workflows/all-workflows.yaml | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/all-workflows.yaml b/.github/workflows/all-workflows.yaml index 5dd3d074..03dee063 100644 --- a/.github/workflows/all-workflows.yaml +++ b/.github/workflows/all-workflows.yaml @@ -21,18 +21,21 @@ jobs: echo "abort=true" >> "$GITHUB_OUTPUT" fi + name: Run only one test + run: Rscript -e 'testthat::test_file("tests/testthat/test-getTableSignature.R")' + # We call the reusable workflow that triggers all AEF-DDF workflows - run-all-AEF-DFF-workflows: - name: ⚙️ Dispatch - needs: context - if: needs.context.outputs.abort != 'true' || contains('main,master', github.ref_name) - uses: ssi-dk/AEF-DDF/.github/workflows/workflow-dispatcher.yaml@main - with: - # We pass information about the triggering event - event_name: ${{ github.event_name }} - run_id: ${{ github.run_id }} + # run-all-AEF-DFF-workflows: + # name: ⚙️ Dispatch + # needs: context + # if: needs.context.outputs.abort != 'true' || contains('main,master', github.ref_name) + # uses: ssi-dk/AEF-DDF/.github/workflows/workflow-dispatcher.yaml@main + # with: + # # We pass information about the triggering event + # event_name: ${{ github.event_name }} + # run_id: ${{ github.run_id }} - # code-coverage creates data bases for the tests. Here you can specify the schemas you need for the workflow - schemas: test,test.one - check_postgres_logs: false - secrets: inherit + # # code-coverage creates data bases for the tests. Here you can specify the schemas you need for the workflow + # schemas: test,test.one + # check_postgres_logs: false + # secrets: inherit From b267f5af6c5e6ca9a4d2787ab93d2401f8dfc20b Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 11:24:03 +0100 Subject: [PATCH 05/36] test: again --- .github/workflows/all-workflows.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/all-workflows.yaml b/.github/workflows/all-workflows.yaml index 03dee063..97fd05d4 100644 --- a/.github/workflows/all-workflows.yaml +++ b/.github/workflows/all-workflows.yaml @@ -21,8 +21,18 @@ jobs: echo "abort=true" >> "$GITHUB_OUTPUT" fi - name: Run only one test - run: Rscript -e 'testthat::test_file("tests/testthat/test-getTableSignature.R")' + run-single: + name: ⚙️ Dispatch + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + outputs: + abort: ${{ steps.pr_detect.outputs.abort }} + steps: + - name: Run one + if: github.event_name == 'push' + id: pr_detect + run: Rscript -e 'testthat::test_file("tests/testthat/test-getTableSignature.R")' # We call the reusable workflow that triggers all AEF-DDF workflows # run-all-AEF-DFF-workflows: From 356d860b0e32e521407d3dbf14e21d37e3e2f9c5 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 11:30:56 +0100 Subject: [PATCH 06/36] test: again ... --- .github/workflows/all-workflows.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/all-workflows.yaml b/.github/workflows/all-workflows.yaml index 97fd05d4..a481f7d6 100644 --- a/.github/workflows/all-workflows.yaml +++ b/.github/workflows/all-workflows.yaml @@ -29,9 +29,17 @@ jobs: outputs: abort: ${{ steps.pr_detect.outputs.abort }} steps: - - name: Run one - if: github.event_name == 'push' + #if: github.event_name == 'push' + - uses: actions/checkout@v3 id: pr_detect + + - name: Set up R + uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + + - name: Run single test file run: Rscript -e 'testthat::test_file("tests/testthat/test-getTableSignature.R")' # We call the reusable workflow that triggers all AEF-DDF workflows From 5876c5adde4328339abed740e2d490cb29232016 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 11:40:32 +0100 Subject: [PATCH 07/36] test: Revering yaml and stepwise test of getTable Signature --- .github/workflows/all-workflows.yaml | 49 +++++++------------------ tests/testthat/test-getTableSignature.R | 7 +++- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/.github/workflows/all-workflows.yaml b/.github/workflows/all-workflows.yaml index a481f7d6..5dd3d074 100644 --- a/.github/workflows/all-workflows.yaml +++ b/.github/workflows/all-workflows.yaml @@ -21,39 +21,18 @@ jobs: echo "abort=true" >> "$GITHUB_OUTPUT" fi - run-single: - name: ⚙️ Dispatch - runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ github.token }} - outputs: - abort: ${{ steps.pr_detect.outputs.abort }} - steps: - #if: github.event_name == 'push' - - uses: actions/checkout@v3 - id: pr_detect - - - name: Set up R - uses: r-lib/actions/setup-r@v2 - - - name: Install dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - - - name: Run single test file - run: Rscript -e 'testthat::test_file("tests/testthat/test-getTableSignature.R")' - # We call the reusable workflow that triggers all AEF-DDF workflows - # run-all-AEF-DFF-workflows: - # name: ⚙️ Dispatch - # needs: context - # if: needs.context.outputs.abort != 'true' || contains('main,master', github.ref_name) - # uses: ssi-dk/AEF-DDF/.github/workflows/workflow-dispatcher.yaml@main - # with: - # # We pass information about the triggering event - # event_name: ${{ github.event_name }} - # run_id: ${{ github.run_id }} - - # # code-coverage creates data bases for the tests. Here you can specify the schemas you need for the workflow - # schemas: test,test.one - # check_postgres_logs: false - # secrets: inherit + run-all-AEF-DFF-workflows: + name: ⚙️ Dispatch + needs: context + if: needs.context.outputs.abort != 'true' || contains('main,master', github.ref_name) + uses: ssi-dk/AEF-DDF/.github/workflows/workflow-dispatcher.yaml@main + with: + # We pass information about the triggering event + event_name: ${{ github.event_name }} + run_id: ${{ github.run_id }} + + # code-coverage creates data bases for the tests. Here you can specify the schemas you need for the workflow + schemas: test,test.one + check_postgres_logs: false + secrets: inherit diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 317209d6..01bc5b94 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -284,8 +284,13 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) - data_random2 <- data_random + data_random2 <- data_random |> dplyr::select(Date, character, integer, numeric) dr_copy <- dplyr::copy_to(conn, data_random2) + data_random3 <- data_random |> dplyr::select(Date, character, integer, numeric, logical) + dr_copy <- dplyr::copy_to(conn, data_random3) + print(dr_copy) + data_random4 <- data_random |> dplyr::select(Date, character, integer, numeric, POSIXct) + dr_copy <- dplyr::copy_to(conn, data_random4) print(dr_copy) print(conn) tt <- getTableSignature(dr_copy, conn) From 251a825a5c799e079bd6beceb8fa0f901ec70818 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 12:00:25 +0100 Subject: [PATCH 08/36] test: POSIXct as only column --- tests/testthat/test-getTableSignature.R | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 01bc5b94..54c11d43 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -284,14 +284,12 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) - data_random2 <- data_random |> dplyr::select(Date, character, integer, numeric) - dr_copy <- dplyr::copy_to(conn, data_random2) - data_random3 <- data_random |> dplyr::select(Date, character, integer, numeric, logical) - dr_copy <- dplyr::copy_to(conn, data_random3) - print(dr_copy) - data_random4 <- data_random |> dplyr::select(Date, character, integer, numeric, POSIXct) + data_random4 <- data.frame(datetime = Sys.time()) dr_copy <- dplyr::copy_to(conn, data_random4) print(dr_copy) + data_random3 <- data_random |> dplyr::select(Date, character, integer, numeric, POSIXct) + dr_copy <- dplyr::copy_to(conn, data_random3) + print(dr_copy) print(conn) tt <- getTableSignature(dr_copy, conn) print(tt) From d06bb23e20121d7de8664683fc98bbe0c6e542a5 Mon Sep 17 00:00:00 2001 From: LasseEngboChr Date: Fri, 28 Mar 2025 11:03:51 +0000 Subject: [PATCH 09/36] chore: Update pak.lock --- pak.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pak.lock b/pak.lock index 3e1d2cbd..170ce589 100644 --- a/pak.lock +++ b/pak.lock @@ -2277,7 +2277,7 @@ { "ref": "jsonlite", "package": "jsonlite", - "version": "1.9.1", + "version": "2.0.0", "type": "standard", "direct": false, "binary": true, @@ -2289,10 +2289,10 @@ "RemoteRef": "jsonlite", "RemoteRepos": "https://packagemanager.posit.co/cran/__linux__/noble/latest", "RemotePkgPlatform": "x86_64-pc-linux-gnu-ubuntu-24.04", - "RemoteSha": "1.9.1" + "RemoteSha": "2.0.0" }, - "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/jsonlite_1.9.1.tar.gz", - "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/jsonlite_1.9.1.tar.gz", + "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/jsonlite_2.0.0.tar.gz", + "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/jsonlite_2.0.0.tar.gz", "platform": "x86_64-pc-linux-gnu-ubuntu-24.04", "rversion": "4.4", "directpkg": false, @@ -2774,7 +2774,7 @@ { "ref": "odbc", "package": "odbc", - "version": "1.6.0", + "version": "1.6.1", "type": "standard", "direct": false, "binary": true, @@ -2786,10 +2786,10 @@ "RemoteRef": "odbc", "RemoteRepos": "https://packagemanager.posit.co/cran/__linux__/noble/latest", "RemotePkgPlatform": "x86_64-pc-linux-gnu-ubuntu-24.04", - "RemoteSha": "1.6.0" + "RemoteSha": "1.6.1" }, - "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/odbc_1.6.0.tar.gz", - "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/odbc_1.6.0.tar.gz", + "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/odbc_1.6.1.tar.gz", + "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/odbc_1.6.1.tar.gz", "platform": "x86_64-pc-linux-gnu-ubuntu-24.04", "rversion": "4.4", "directpkg": false, @@ -4256,7 +4256,7 @@ { "ref": "stringi", "package": "stringi", - "version": "1.8.4", + "version": "1.8.7", "type": "standard", "direct": false, "binary": true, @@ -4268,10 +4268,10 @@ "RemoteRef": "stringi", "RemoteRepos": "https://packagemanager.posit.co/cran/__linux__/noble/latest", "RemotePkgPlatform": "x86_64-pc-linux-gnu-ubuntu-24.04", - "RemoteSha": "1.8.4" + "RemoteSha": "1.8.7" }, - "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/stringi_1.8.4.tar.gz", - "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/stringi_1.8.4.tar.gz", + "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/stringi_1.8.7.tar.gz", + "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/stringi_1.8.7.tar.gz", "platform": "x86_64-pc-linux-gnu-ubuntu-24.04", "rversion": "4.4", "directpkg": false, From 614eb40714edcb2de5e9f056436b67d3c62fbd61 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 13:23:32 +0100 Subject: [PATCH 10/36] test: Avoiding |> --- tests/testthat/test-getTableSignature.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 54c11d43..90e968e1 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -287,7 +287,7 @@ for (conn in c(list(NULL), get_test_conns())) { data_random4 <- data.frame(datetime = Sys.time()) dr_copy <- dplyr::copy_to(conn, data_random4) print(dr_copy) - data_random3 <- data_random |> dplyr::select(Date, character, integer, numeric, POSIXct) + data_random3 <- dplyr::select(.data = data_random, Date, character, integer, numeric, POSIXct) dr_copy <- dplyr::copy_to(conn, data_random3) print(dr_copy) print(conn) From 3ac9a2f3705dffe5d9e41256233b61da4f3956ed Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 15:50:19 +0100 Subject: [PATCH 11/36] test: Trying if DBI::dbWriteTable also produces the error - it works on SQL Server 2019. --- tests/testthat/test-getTableSignature.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 90e968e1..3bfa27d2 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -285,11 +285,9 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) - dr_copy <- dplyr::copy_to(conn, data_random4) - print(dr_copy) - data_random3 <- dplyr::select(.data = data_random, Date, character, integer, numeric, POSIXct) - dr_copy <- dplyr::copy_to(conn, data_random3) - print(dr_copy) + DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary =TRUE) + #dr_copy <- dplyr::copy_to(conn, data_random4) + print(tbl(conn, "#testthis")) print(conn) tt <- getTableSignature(dr_copy, conn) print(tt) From 10257f978c519e8b50191bafbe2963b7c2dae4c6 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:05:33 +0100 Subject: [PATCH 12/36] tesst: added prexix --- tests/testthat/test-getTableSignature.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 3bfa27d2..f71f1970 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -285,10 +285,10 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) - DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary =TRUE) - #dr_copy <- dplyr::copy_to(conn, data_random4) - print(tbl(conn, "#testthis")) + DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis")) print(conn) + dr_copy <- dplyr::copy_to(conn, data_random4) tt <- getTableSignature(dr_copy, conn) print(tt) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { From bf7bb95755a7fa0980fbce7beee68382d887dd54 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:26:49 +0100 Subject: [PATCH 13/36] test:steps --- tests/testthat/test-getTableSignature.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index f71f1970..3f16a537 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -287,7 +287,16 @@ for (conn in c(list(NULL), get_test_conns())) { data_random4 <- data.frame(datetime = Sys.time()) DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary = TRUE) print(dplyr::tbl(conn, "#testthis")) - print(conn) + print("testthis done") + DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis2")) + print("testthis2 done") + dplyr::db_write_table(conn, "#testthis3", value = data_random, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis3")) + print("testthis3 done") + dbplyr::db_copy_to(conn, "#testthis4", value = data_random, temporary = TRUE) + print("testthis4 done") + dr_copy <- dplyr::copy_to(conn, data_random4) tt <- getTableSignature(dr_copy, conn) print(tt) From e2ed56883041922facd97ee441c3a810e1ed28ab Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:38:31 +0100 Subject: [PATCH 14/36] test: with as_table_path --- tests/testthat/test-getTableSignature.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 3f16a537..3f38fadd 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -291,13 +291,14 @@ for (conn in c(list(NULL), get_test_conns())) { DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2")) print("testthis2 done") - dplyr::db_write_table(conn, "#testthis3", value = data_random, temporary = TRUE) + dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis3")) print("testthis3 done") dbplyr::db_copy_to(conn, "#testthis4", value = data_random, temporary = TRUE) print("testthis4 done") dr_copy <- dplyr::copy_to(conn, data_random4) + print(dr_copy) tt <- getTableSignature(dr_copy, conn) print(tt) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { From 3cc1b132a903f4d6ccbfc800f0407b6cf8d3b847 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:41:39 +0100 Subject: [PATCH 15/36] test: 2B added --- tests/testthat/test-getTableSignature.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 3f38fadd..0c9a8b44 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -291,6 +291,9 @@ for (conn in c(list(NULL), get_test_conns())) { DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2")) print("testthis2 done") + DBI::dbWriteTable(conn, dbplyr::as_table_path("#testthis2B", conn), value = data_random, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis2B")) + print("testthis2B done") dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis3")) print("testthis3 done") From b13a10e7532ce8e74c7fa95b47b331d245624b73 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:44:14 +0100 Subject: [PATCH 16/36] test: adding SQL --- tests/testthat/test-getTableSignature.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 0c9a8b44..08ae533f 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -291,7 +291,7 @@ for (conn in c(list(NULL), get_test_conns())) { DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2")) print("testthis2 done") - DBI::dbWriteTable(conn, dbplyr::as_table_path("#testthis2B", conn), value = data_random, temporary = TRUE) + DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B", conn)), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2B")) print("testthis2B done") dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) From 85958cb42efc65af46a295739c77fddf58cc850a Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 16:57:18 +0100 Subject: [PATCH 17/36] test: again and again --- tests/testthat/test-getTableSignature.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 08ae533f..0e626316 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -285,18 +285,40 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) + + data_ok <- data.frame( + "Date" = Sys.Date(), + "character" = "test", + "integer" = 1L, + "numeric" = 1, + "logical" = TRUE + ) + DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary = TRUE) print(dplyr::tbl(conn, "#testthis")) print("testthis done") + DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2")) print("testthis2 done") + + DBI::dbWriteTable(conn, DBI::SQL("#testthis2A"), value = data_random, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis2A")) + print("testthis2A done") + + DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B0", conn)), value = data_ok, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis2B0")) + print("testthis2B0 done") + + DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B", conn)), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2B")) print("testthis2B done") + dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis3")) print("testthis3 done") + dbplyr::db_copy_to(conn, "#testthis4", value = data_random, temporary = TRUE) print("testthis4 done") From f85ff97176b962058bb71293dbfea935d66ab64b Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 17:04:24 +0100 Subject: [PATCH 18/36] test: -ing --- tests/testthat/test-getTableSignature.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 0e626316..734d4cd0 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -302,14 +302,14 @@ for (conn in c(list(NULL), get_test_conns())) { print(dplyr::tbl(conn, "#testthis2")) print("testthis2 done") - DBI::dbWriteTable(conn, DBI::SQL("#testthis2A"), value = data_random, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis2A")) - print("testthis2A done") - DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B0", conn)), value = data_ok, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2B0")) print("testthis2B0 done") + DBI::dbWriteTable(conn, DBI::SQL("#testthis2A"), value = data_random, temporary = TRUE) + print(dplyr::tbl(conn, "#testthis2A")) + print("testthis2A done") + DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B", conn)), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis2B")) From 805775af6963ae88f8fd7474d114ef46b2e5bc0b Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Fri, 28 Mar 2025 17:33:18 +0100 Subject: [PATCH 19/36] test: This is hard --- tests/testthat/test-getTableSignature.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 734d4cd0..66e068b0 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -294,6 +294,9 @@ for (conn in c(list(NULL), get_test_conns())) { "logical" = TRUE ) + print(DBI::dbDataType(conn, data_random)) + print(DBI::dbDataType(conn, data_ok)) + DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary = TRUE) print(dplyr::tbl(conn, "#testthis")) print("testthis done") From 5ad24c78482d80d5ce675c0770d283f9b7bd9d3f Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Sun, 30 Mar 2025 10:08:25 +0200 Subject: [PATCH 20/36] test: minimal example lines 286++ --- tests/testthat/test-getTableSignature.R | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 66e068b0..16ec11ca 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -286,6 +286,7 @@ for (conn in c(list(NULL), get_test_conns())) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) + # Making a minimal test data_ok <- data.frame( "Date" = Sys.Date(), "character" = "test", @@ -294,29 +295,29 @@ for (conn in c(list(NULL), get_test_conns())) { "logical" = TRUE ) - print(DBI::dbDataType(conn, data_random)) - print(DBI::dbDataType(conn, data_ok)) - - DBI::dbWriteTable(conn, "#testthis", value = data_random4, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis")) - print("testthis done") + data_datetime <- data_ok + data_datetime$datetime <- Sys.time() - DBI::dbWriteTable(conn, "#testthis2", value = data_random, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis2")) - print("testthis2 done") + print(conn) + # Wanted to do + # my_copy <- dplyr::copy_to(conn, data_datetime) - DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B0", conn)), value = data_ok, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis2B0")) - print("testthis2B0 done") + DBI::dbWriteTable(conn, "#testthis", value = data_datetime, temporary = TRUE) + print("testthis done") - DBI::dbWriteTable(conn, DBI::SQL("#testthis2A"), value = data_random, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis2A")) + # dplyr::copy_to effectively calls SQL(as_table_path()) + # First without a datatime column + DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2A", conn)), value = data_ok, temporary = TRUE) print("testthis2A done") - - DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2B", conn)), value = data_random, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis2B")) + # Then with a datatime column + DBI::dbWriteTable(conn, DBI::SQL("#testthis2B"), value = data_datetime, temporary = TRUE) print("testthis2B done") + # We never get here + + print(DBI::dbDataType(conn, data_random)) + print(DBI::dbDataType(conn, data_ok)) + dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) print(dplyr::tbl(conn, "#testthis3")) From 98c99838ea97d03ec99ccc872473239251722a46 Mon Sep 17 00:00:00 2001 From: LasseEngboChr Date: Sun, 30 Mar 2025 08:10:44 +0000 Subject: [PATCH 21/36] chore: Update pak.lock --- pak.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pak.lock b/pak.lock index 170ce589..2ee0ff5c 100644 --- a/pak.lock +++ b/pak.lock @@ -255,11 +255,11 @@ { "ref": "broom", "package": "broom", - "version": "1.0.7", + "version": "1.0.8", "type": "standard", "direct": false, "binary": true, - "dependencies": ["backports", "dplyr", "generics", "glue", "lifecycle", "purrr", "rlang", "stringr", "tibble", "tidyr"], + "dependencies": ["backports", "cli", "dplyr", "generics", "glue", "lifecycle", "purrr", "rlang", "stringr", "tibble", "tidyr"], "vignettes": false, "metadata": { "RemotePkgRef": "broom", @@ -267,10 +267,10 @@ "RemoteRef": "broom", "RemoteRepos": "https://packagemanager.posit.co/cran/__linux__/noble/latest", "RemotePkgPlatform": "x86_64-pc-linux-gnu-ubuntu-24.04", - "RemoteSha": "1.0.7" + "RemoteSha": "1.0.8" }, - "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/broom_1.0.7.tar.gz", - "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/broom_1.0.7.tar.gz", + "sources": "https://packagemanager.posit.co/cran/__linux__/noble/latest/src/contrib/broom_1.0.8.tar.gz", + "target": "src/contrib/x86_64-pc-linux-gnu-ubuntu-24.04/4.4/broom_1.0.8.tar.gz", "platform": "x86_64-pc-linux-gnu-ubuntu-24.04", "rversion": "4.4", "directpkg": false, From 074330b1b6fd26b6bb37ec69cc43cce4c61b8784 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Sun, 30 Mar 2025 10:44:07 +0200 Subject: [PATCH 22/36] test: packageVersion --- tests/testthat/test-getTableSignature.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 16ec11ca..273ffb88 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -285,6 +285,13 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) + print("ODBC") + packageVersion("odbc") + print("DBI") + packageVersion("DBI") + print("dplyr") + packageVersion("dplyr") + # Making a minimal test data_ok <- data.frame( From 5818a38a5b38872db9542084b85d54c9ad0e71bb Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Sun, 30 Mar 2025 10:45:03 +0200 Subject: [PATCH 23/36] test: printing package versions --- tests/testthat/test-getTableSignature.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 273ffb88..b23ae43c 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -286,11 +286,11 @@ for (conn in c(list(NULL), get_test_conns())) { print(conn) data_random4 <- data.frame(datetime = Sys.time()) print("ODBC") - packageVersion("odbc") + print(packageVersion("odbc")) print("DBI") - packageVersion("DBI") + print(packageVersion("DBI")) print("dplyr") - packageVersion("dplyr") + print(packageVersion("dplyr")) # Making a minimal test From 7cec2face33774f779ae1db0b38cb4e900591730 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Sun, 30 Mar 2025 10:48:58 +0200 Subject: [PATCH 24/36] test: Added Sys.info --- tests/testthat/test-getTableSignature.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index b23ae43c..622304e9 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -291,6 +291,7 @@ for (conn in c(list(NULL), get_test_conns())) { print(packageVersion("DBI")) print("dplyr") print(packageVersion("dplyr")) + print(Sys.info()) # Making a minimal test From b1cd2b6ee5cb9b2fee3dff9d49d285697925c9ff Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 09:04:15 +0200 Subject: [PATCH 25/36] test:trying the fix from odbc --- tests/testthat/test-getTableSignature.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 622304e9..7d2ebbc1 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,6 +31,11 @@ data_random <- data.frame( "logical" = TRUE ) +print("Installing ODBC") +devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") +print("Done: Installing ODBC") + + for (conn in c(list(NULL), get_test_conns())) { if (is.null(conn)) { @@ -283,6 +288,11 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { + selectMethod(odbc:::odbcConnectionColumns_, c("Microsoft SQL Server", "SQL")) + library(odbc) + print("New?") + selectMethod(odbc:::odbcConnectionColumns_, c("Microsoft SQL Server", "SQL")) + print(conn) data_random4 <- data.frame(datetime = Sys.time()) print("ODBC") From 1b57d4f1dfda58de40111b6fe8af6cc6adef2816 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 09:12:29 +0200 Subject: [PATCH 26/36] test: Testing fix from ODBC part 2 --- tests/testthat/test-getTableSignature.R | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 7d2ebbc1..cf87ea0c 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -337,14 +337,7 @@ for (conn in c(list(NULL), get_test_conns())) { print(DBI::dbDataType(conn, data_ok)) - dplyr::db_write_table(conn, dbplyr::as_table_path("#testthis3", conn), value = data_random, temporary = TRUE) - print(dplyr::tbl(conn, "#testthis3")) - print("testthis3 done") - - dbplyr::db_copy_to(conn, "#testthis4", value = data_random, temporary = TRUE) - print("testthis4 done") - - dr_copy <- dplyr::copy_to(conn, data_random4) + dr_copy <- dplyr::copy_to(conn, data_random) print(dr_copy) tt <- getTableSignature(dr_copy, conn) print(tt) From 4e9b419e1fee745e77be3df3c06f7c9e35cb8bd9 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 09:30:01 +0200 Subject: [PATCH 27/36] fix: Reverting most in the test. Maintaining a install_github from the branch as long as 1.6.1 is the default ODBC version, --- tests/testthat/test-getTableSignature.R | 68 ++++--------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index cf87ea0c..c9e83e22 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,13 +31,18 @@ data_random <- data.frame( "logical" = TRUE ) -print("Installing ODBC") -devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") -print("Done: Installing ODBC") - +print(packageVersion("ODBC")) # Delete this block when ODBC is updated +if (packageVersion("ODBC") < '1.6.1.9000') { + print("Installing ODBC") + devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") +} for (conn in c(list(NULL), get_test_conns())) { + if (inherits(conn, "Microsoft SQL Server")) { + options("odbc.batch_rows" = 1000) + } + if (is.null(conn)) { test_that("getTableSignature() generates signature for update_snapshot() (conn == NULL)", { expect_identical( @@ -288,62 +293,11 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { - selectMethod(odbc:::odbcConnectionColumns_, c("Microsoft SQL Server", "SQL")) - library(odbc) - print("New?") - selectMethod(odbc:::odbcConnectionColumns_, c("Microsoft SQL Server", "SQL")) - - print(conn) - data_random4 <- data.frame(datetime = Sys.time()) - print("ODBC") - print(packageVersion("odbc")) - print("DBI") - print(packageVersion("DBI")) - print("dplyr") - print(packageVersion("dplyr")) - print(Sys.info()) - - - # Making a minimal test - data_ok <- data.frame( - "Date" = Sys.Date(), - "character" = "test", - "integer" = 1L, - "numeric" = 1, - "logical" = TRUE - ) - - data_datetime <- data_ok - data_datetime$datetime <- Sys.time() - - print(conn) - # Wanted to do - # my_copy <- dplyr::copy_to(conn, data_datetime) - - DBI::dbWriteTable(conn, "#testthis", value = data_datetime, temporary = TRUE) - print("testthis done") - - # dplyr::copy_to effectively calls SQL(as_table_path()) - # First without a datatime column - DBI::dbWriteTable(conn, DBI::SQL(dbplyr::as_table_path("#testthis2A", conn)), value = data_ok, temporary = TRUE) - print("testthis2A done") - - # Then with a datatime column - DBI::dbWriteTable(conn, DBI::SQL("#testthis2B"), value = data_datetime, temporary = TRUE) - print("testthis2B done") - # We never get here - - print(DBI::dbDataType(conn, data_random)) - print(DBI::dbDataType(conn, data_ok)) - - dr_copy <- dplyr::copy_to(conn, data_random) - print(dr_copy) - tt <- getTableSignature(dr_copy, conn) - print(tt) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { + dr_copy <- dplyr::copy_to(conn, data_random) expect_identical( - tt, + getTableSignature(dr_copy, conn), c( "Date" = "DATE", "POSIXct" = "DATETIME", From 5e54224faeb0bf1d080f0218f44b89fa64db65aa Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 11:24:29 +0200 Subject: [PATCH 28/36] fix: ODBC -> odbc --- tests/testthat/test-getTableSignature.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index c9e83e22..a1c8e482 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,8 +31,8 @@ data_random <- data.frame( "logical" = TRUE ) -print(packageVersion("ODBC")) # Delete this block when ODBC is updated -if (packageVersion("ODBC") < '1.6.1.9000') { +print(packageVersion("odbc")) # Delete this block when ODBC is updated +if (packageVersion("odbc") < '1.6.1.9000') { print("Installing ODBC") devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") } From de728353d74090c240015acfffb7426fa2e68d09 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 11:35:27 +0200 Subject: [PATCH 29/36] fix: Small adjustments --- tests/testthat/test-getTableSignature.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index a1c8e482..184d6ad2 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,10 +31,13 @@ data_random <- data.frame( "logical" = TRUE ) -print(packageVersion("odbc")) # Delete this block when ODBC is updated -if (packageVersion("odbc") < '1.6.1.9000') { - print("Installing ODBC") - devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") +cat(packageVersion("odbc")) # Delete this block when ODBC is updated +if (packageVersion("odbc") < "1.6.1.9000") { + cat(" Installing ODBC \n") + devtools::install_github( + repo = "detule/odbc", + ref = "fixup/columns_exact_propagation" + ) } for (conn in c(list(NULL), get_test_conns())) { @@ -295,6 +298,7 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { + cat("ODBC ", packageVersion("odbc"), "\n") dr_copy <- dplyr::copy_to(conn, data_random) expect_identical( getTableSignature(dr_copy, conn), From c7e3b3aae3eb2cfd42640f39beb986130011f51f Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 11:45:05 +0200 Subject: [PATCH 30/36] fix: cat cannot print a list and packageVersion returns a list --- tests/testthat/test-getTableSignature.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 184d6ad2..682094bf 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,8 +31,8 @@ data_random <- data.frame( "logical" = TRUE ) -cat(packageVersion("odbc")) # Delete this block when ODBC is updated -if (packageVersion("odbc") < "1.6.1.9000") { +cat(paste0(unlist(packageVersion("odbc")), collapse = ".")) # Delete this block when ODBC is updated +if (paste0(unlist(packageVersion("odbc")), collapse = ".") < "1.6.1.9000") { cat(" Installing ODBC \n") devtools::install_github( repo = "detule/odbc", @@ -298,7 +298,7 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { - cat("ODBC ", packageVersion("odbc"), "\n") + cat("ODBC ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") dr_copy <- dplyr::copy_to(conn, data_random) expect_identical( getTableSignature(dr_copy, conn), From 56d863efe21e556d053c17db1713a21c522431cb Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 11:56:56 +0200 Subject: [PATCH 31/36] test: Why do I get the wrong version now --- tests/testthat/test-getTableSignature.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 682094bf..88c804d0 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -31,7 +31,8 @@ data_random <- data.frame( "logical" = TRUE ) -cat(paste0(unlist(packageVersion("odbc")), collapse = ".")) # Delete this block when ODBC is updated +cat(paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") # Delete this block when ODBC is updated +cat(search(), "\n") if (paste0(unlist(packageVersion("odbc")), collapse = ".") < "1.6.1.9000") { cat(" Installing ODBC \n") devtools::install_github( From ab40510781b04afef49bcdac036c99b717c6e422 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 13:01:55 +0200 Subject: [PATCH 32/36] test: Don't know why it loads the wrong version now. Forcing installation --- tests/testthat/test-getTableSignature.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 88c804d0..62bedb64 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -33,13 +33,14 @@ data_random <- data.frame( cat(paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") # Delete this block when ODBC is updated cat(search(), "\n") -if (paste0(unlist(packageVersion("odbc")), collapse = ".") < "1.6.1.9000") { - cat(" Installing ODBC \n") - devtools::install_github( - repo = "detule/odbc", - ref = "fixup/columns_exact_propagation" - ) -} +#if (paste0(unlist(packageVersion("odbc")), collapse = ".") < "1.6.1.9000") { +cat(" Installing ODBC \n") +devtools::install_github( + repo = "detule/odbc", + ref = "fixup/columns_exact_propagation" +) +#} +cat(paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") # Delete this block when ODBC is updated for (conn in c(list(NULL), get_test_conns())) { From dcb68b5fad7dd99ccb1cbaff0b32e4b121d82517 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 13:37:54 +0200 Subject: [PATCH 33/36] test: Moving copy_to out of test_that(...) --- tests/testthat/test-getTableSignature.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 62bedb64..d8ccea1f 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -298,10 +298,10 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { + cat("ODBC ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") + dr_copy <- dplyr::copy_to(conn, data_random) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { - cat("ODBC ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") - dr_copy <- dplyr::copy_to(conn, data_random) expect_identical( getTableSignature(dr_copy, conn), c( From bb74021401c13371c42f91553a78c91de82f21a2 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 13:48:53 +0200 Subject: [PATCH 34/36] test: Trying a small mod --- tests/testthat/test-getTableSignature.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index d8ccea1f..6c7c92b9 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -40,7 +40,7 @@ devtools::install_github( ref = "fixup/columns_exact_propagation" ) #} -cat(paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") # Delete this block when ODBC is updated +cat("Installed: ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") for (conn in c(list(NULL), get_test_conns())) { @@ -299,7 +299,8 @@ for (conn in c(list(NULL), get_test_conns())) { if (inherits(conn, "Microsoft SQL Server")) { cat("ODBC ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") - dr_copy <- dplyr::copy_to(conn, data_random) + data_random2 <- data_random + dr_copy <- dplyr::copy_to(conn, data_random2) test_that("getTableSignature() generates signature for random data on remote (Microsoft SQL Server)", { expect_identical( From 8f8090b368c9df01ac936c597e34febdd9f1ca8b Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 13:50:30 +0200 Subject: [PATCH 35/36] fix: lintr --- tests/testthat/test-getTableSignature.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 6c7c92b9..2bb0d35d 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -44,9 +44,9 @@ cat("Installed: ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") for (conn in c(list(NULL), get_test_conns())) { - if (inherits(conn, "Microsoft SQL Server")) { - options("odbc.batch_rows" = 1000) - } + if (inherits(conn, "Microsoft SQL Server")) { + options("odbc.batch_rows" = 1000) + } if (is.null(conn)) { test_that("getTableSignature() generates signature for update_snapshot() (conn == NULL)", { From a55047afde2b2bea1ad231e7ddcbc8b86a722f70 Mon Sep 17 00:00:00 2001 From: Lasse Engbo Christiansen Date: Mon, 31 Mar 2025 14:35:49 +0200 Subject: [PATCH 36/36] test: loading odbc library --- tests/testthat/test-getTableSignature.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-getTableSignature.R b/tests/testthat/test-getTableSignature.R index 2bb0d35d..34b8bd72 100644 --- a/tests/testthat/test-getTableSignature.R +++ b/tests/testthat/test-getTableSignature.R @@ -35,10 +35,7 @@ cat(paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") # Delete this cat(search(), "\n") #if (paste0(unlist(packageVersion("odbc")), collapse = ".") < "1.6.1.9000") { cat(" Installing ODBC \n") -devtools::install_github( - repo = "detule/odbc", - ref = "fixup/columns_exact_propagation" -) +devtools::install_github(repo = "detule/odbc", ref = "fixup/columns_exact_propagation") #} cat("Installed: ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") @@ -298,6 +295,7 @@ for (conn in c(list(NULL), get_test_conns())) { } if (inherits(conn, "Microsoft SQL Server")) { + library(odbc) cat("ODBC ", paste0(unlist(packageVersion("odbc")), collapse = "."), "\n") data_random2 <- data_random dr_copy <- dplyr::copy_to(conn, data_random2)