fix: preserve names in str_sub<-()#607
Closed
LeonidasZhak wants to merge 2 commits into
Closed
Conversation
…tr_squish Add edge-case tests for data cleaning scenarios: - NA passthrough in str_trim (all side variants) and str_squish - Empty string and whitespace-only string handling - Newlines, CRLF, and mixed whitespace in str_squish The DESCRIPTION promises consistent NA handling but these cases were untested. str_trunc has analogous NA tests (test-trunc.R:1-10).
str_sub<-() drops names because stri_sub<-() doesn't preserve them. This also caused str_to_camel() to lose names when first_upper = FALSE. Save and restore names around the stri_sub<-() call.
Author
|
Withdrawing this because checks are failing and I should not ask maintainers to review an unready automated PR. Sorry for the noise, and thank you for maintaining stringr. |
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.
Problem
str_sub<-()drops names becausestri_sub<-()doesn't preserve them. This also affectsstr_to_camel(), which loses names whenfirst_upper = FALSE(the default):Fix
Save and restore names around the
stri_sub<-()call instr_sub<-(). This is consistent with howstr_sub()(the getter) already preserves names viacopy_names().R/sub.R: 2 lines added.
Tests
tests/testthat/test-sub.R: Added test verifyingstr_sub<-()preserves namestests/testthat/test-case.R: Added test verifyingstr_to_camel(),str_to_snake(), andstr_to_kebab()preserve namesValidation