fix: warn when strl_threshold is out-of-range instead of silent clipping#821
Open
LeonidasZhak wants to merge 2 commits into
Open
fix: warn when strl_threshold is out-of-range instead of silent clipping#821LeonidasZhak wants to merge 2 commits into
LeonidasZhak wants to merge 2 commits into
Conversation
- Add test verifying write_dta() strl_threshold correctly controls strL vs str# storage with both low (50) and high (5000) thresholds - Fix 'udpates' -> 'updates' typo in test-as_factor.R test description
validate_strl_threshold() previously silently clipped out-of-range values (< 0 or > 2045) to 2045 without informing the user. Now it emits a cli_warn() so users know their value was adjusted. - R/haven-stata.R: add cli_warn() in validate_strl_threshold() - tests/testthat/test-haven-stata.R: add test for out-of-range warning behavior; update existing test to expect_warning()
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
validate_strl_threshold()previously silently clipped out-of-range values (< 0 or > 2045) to 2045 without informing the user. This PR adds acli_warn()so users know their value was adjusted.Changes
R/haven-stata.Rcli_warn()invalidate_strl_threshold()when clipping occurstests/testthat/test-haven-stata.Rexpect_warning()Motivation
If a user passes
strl_threshold = 5000, they expect strings > 5000 bytes to use strL storage. But the value was silently clipped to 2045 (the max str# length). Now the user gets a warning:Validation
devtools::test(filter = "haven-stata"): 70 PASS, 0 new failuresdevtools::test(): 474 PASS, 2 pre-existing failures (labelled-pillar snapshot, haven-sas deprecation)Notes
call = caller_env()pattern for proper error attribution