Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve integer64 class #309

Closed
wants to merge 1 commit into from
Closed

Preserve integer64 class #309

wants to merge 1 commit into from

Conversation

nbenn
Copy link
Member

@nbenn nbenn commented Nov 25, 2023

Something like this solves my problem. Whether it's a smart move to fix something that's essentially an upstream issue in such a way is an open question to me. Happy to discuss @krlmlr.

Fixes #308.

Copy link
Contributor

aviator-app bot commented Nov 25, 2023

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was closed without merging. If you still want to merge this PR, re-open it.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@krlmlr
Copy link
Member

krlmlr commented Nov 26, 2023

Thanks. The RSQLite reprex now gives different results, still with failures. I assume this is because RSQLite doesn't return int64 logicals. Do you have an example of an actual driver where this change gives better results?

I'd also like to limit the impact of this change to where it matters. Can we perhaps change the definition of the logical_return tweak so that it returns a list of int64 values right away, and we can keep DBItest unchanged? The following still fails, but seems to have correct values:

ctx <- DBItest::make_context(
  RSQLite::SQLite(),
  list(
    dbname = tempfile("DBItest", fileext = ".sqlite"),
    bigint = "integer64"
  ),
  tweaks = DBItest::tweaks(
    logical_return = function(x) lapply(x, bit64::as.integer64)
  )
)

DBItest::test_some("data_logical", ctx, FALSE)
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 1L] not identical to structure(4.94065645841247e-324, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "none") at DBItest/R/spec-result-roundtrip.R:262:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 1L], `<int64>`)
#> 
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 2L] not identical to structure(0, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "none") at DBItest/R/spec-result-roundtrip.R:262:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 2L], `<int64>`)
#> 
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 1L] not identical to structure(4.94065645841247e-324, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "above") at DBItest/R/spec-result-roundtrip.R:263:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 1L], `<int64>`)
#> 
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 2L] not identical to structure(0, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "above") at DBItest/R/spec-result-roundtrip.R:263:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 2L], `<int64>`)
#> 
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 1L] not identical to structure(4.94065645841247e-324, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "below") at DBItest/R/spec-result-roundtrip.R:264:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 1L], `<int64>`)
#> 
#> ── Failure: DBItest: Result: data_logical ──────────────────────────────────────
#> rows[1L, 2L] not identical to structure(0, class = "integer64").
#> Classes differ: 'integer' is not 'integer64'
#> Backtrace:
#>      ▆
#>   1. ├─rlang::exec(test_fun, !!!args) at DBItest/R/run.R:77:11
#>   2. └─DBItest (local) `<fn>`(ctx = `<DBItst_c>`, con = `<SQLtCnnc>`)
#>   3.   ├─testthat::expect_warning(...) at DBItest/R/spec-result-roundtrip.R:29:5
#>   4.   │ └─testthat:::quasi_capture(...)
#>   5.   │   ├─testthat (local) .capture(...)
#>   6.   │   │ └─base::withCallingHandlers(...)
#>   7.   │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
#>   8.   └─DBItest:::test_select_with_null(...)
#>   9.     └─DBItest:::test_select(..., .add_null = "below") at DBItest/R/spec-result-roundtrip.R:264:3
#>  10.       ├─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun)))) at DBItest/R/spec-result-roundtrip.R:328:7
#>  11.       │ └─base::eval(bquote(expect_identical(rows[1L, .(i)], .(value_or_testfun))))
#>  12.       └─testthat::expect_identical(rows[1L, 2L], `<int64>`)
#> Error:
#> ! Test failed
#> Backtrace:
#>      ▆
#>   1. └─DBItest::test_some("data_logical", ctx, FALSE)
#>   2.   └─DBItest::test_all(run_only = test, skip = character(), ctx = ctx) at DBItest/R/test-all.R:56:3
#>   3.     └─DBItest::test_result(skip = skip, run_only = run_only, ctx = ctx) at DBItest/R/test-all.R:29:3
#>   4.       └─DBItest:::run_tests(ctx, spec_result, skip, run_only, test_suite) at DBItest/R/test-result.R:17:3
#>   5.         └─base::vapply(...) at DBItest/R/run.R:32:3
#>   6.           └─DBItest (local) FUN(X[[i]], ...)
#>   7.             └─testthat::test_that(...) at DBItest/R/run.R:42:9
#>   8.               └─withr (local) `<fn>`(`<env>`) at DBItest/R/run.R:42:9
#>   9.                 ├─base::tryCatch(...)
#>  10.                 │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  11.                 │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  12.                 │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  13.                 └─base::eval(handler$expr, handler$envir)
#>  14.                   └─base::eval(handler$expr, handler$envir)
#>  15.                     └─reporter$stop_if_needed()
#>  16.                       └─rlang::abort("Test failed", call = NULL)

Created on 2023-11-26 with reprex v2.0.2

@aviator-app aviator-app bot force-pushed the 308-int64-lgl branch 28 times, most recently from 2d6e098 to 3d778fe Compare December 21, 2023 09:17
@aviator-app aviator-app bot force-pushed the 308-int64-lgl branch 10 times, most recently from 954fb7d to e6d92c1 Compare December 24, 2023 11:35
@krlmlr
Copy link
Member

krlmlr commented Mar 30, 2024

Solved differently, I think.

@krlmlr krlmlr closed this Mar 30, 2024
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.

Cannot use bit64::integer64() as logical values
2 participants