Repository navigation
fix: preserve exact double literals without forcing scientific notation - #688
Closed
LeonidasZhak wants to merge 2 commits into
Closed
LeonidasZhak wants to merge 2 commits into
LeonidasZhak wants to merge 2 commits into
Conversation
Author
|
Following up on this PR: the latest |
This was referenced Nov 28, 2026
Member
|
Thank you. I'm prepared to this limitation in DBI, users who need ultra-high precision need to quote themselves. I'm willing to reconsider branch-free code that uses exactly one way to convert accurately in all or almost all cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve exact
doubleliterals indbQuoteLiteral()only when the default formatting would lose precision.Thanks to maintainers
Thanks for the original issue discussion and for reverting the earlier scientific-notation change once reverse dependencies showed it was too broad.
Issue or motivation
DBI::dbQuoteLiteral()currently usesas.character()fordoublevalues. That loses precision for some values reported in#404, so quoted literals do not always round-trip back to the original number.Root cause
The default character conversion for
doublevalues is readable, but it is not guaranteed to preserve the original binary value. The earlier fix switched all doubles to scientific notation, which fixed precision but changed unaffected literals more broadly than necessary.Change
as.character()output when it already round-trips exactly.formatC(..., digits = 17, format = "fg", flag = "#")only for finitedoublevalues where the default formatting loses precision.Tests
Rscript -e 'pkgload::load_all(\".\", quiet = TRUE); testthat::test_file(\"tests/testthat/test-quoting.R\")'Rscript -e 'pkgload::load_all(\".\", quiet = TRUE); testthat::test_file(\"tests/testthat/test-sql-df.R\"); testthat::test_file(\"tests/testthat/test-interpolate.R\")'R CMD build .R CMD check --no-manual DBI_1.3.0.9010.tar.gzScope
This does not change integer or logical quoting, does not reintroduce scientific notation for all doubles, and does not include the unrelated generated vignette file changes from local checks.