feat: add DataType::Char and add LEN to Describe#174
Merged
KKould merged 8 commits intoKipData:mainfrom Mar 21, 2024
Merged
Conversation
crwen
reviewed
Mar 21, 2024
crwen
reviewed
Mar 21, 2024
crwen
reviewed
Mar 21, 2024
Comment on lines
+453
to
+460
| // https://dev.mysql.com/doc/refman/8.0/en/char.html#:~:text=If%20a%20given%20value%20is%20stored%20into%20the%20CHAR(4)%20and%20VARCHAR(4)%20columns%2C%20the%20values%20retrieved%20from%20the%20columns%20are%20not%20always%20the%20same%20because%20trailing%20spaces%20are%20removed%20from%20CHAR%20columns%20upon%20retrieval.%20The%20following%20example%20illustrates%20this%20difference%3A | ||
| let value = (!bytes.is_empty()).then(|| { | ||
| let last_non_zero_index = match bytes.iter().rposition(|&x| x != b' ') { | ||
| Some(index) => index + 1, | ||
| None => 0, | ||
| }; | ||
| String::from_utf8(bytes[0..last_non_zero_index].to_owned()).unwrap() | ||
| }); |
Member
There was a problem hiding this comment.
maybe use trim_end()
String::from_utf8(bytes.to_owned()).unwrap().trim_end();and the link is too long 😂
Member
Author
There was a problem hiding this comment.
I tried it and it will make ' foo ' become 'foo', but it should be ' foo' in mysql
Member
There was a problem hiding this comment.
trim_end only remove trailing whitespace. You might used trim().
Member
Author
There was a problem hiding this comment.
trim_endonly remove trailing whitespace. You might usedtrim().
oh, you are right, but I found that trim_end() returns &str, which may cause String to be copied again.
crwen
approved these changes
Mar 21, 2024
9 tasks
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.
What problem does this PR solve?
on mysql
Issue link: #130
Code changes
Check List
Tests
Side effects
Note for reviewer