Skip to content

Commit

Permalink
fix: replace fill symbol '\0' -> ' ' for LogicalType::Char
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Mar 21, 2024
1 parent 7d1063f commit 9e35bf0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/types/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Tuple {
let difference = len.saturating_sub(value_bytes.len());

bytes.append(&mut value_bytes);
bytes.append(&mut vec![0; difference]);
bytes.append(&mut vec![b' '; difference]);
} else {
bytes.append(&mut (value_bytes.len() as u32).encode_fixed_vec());
bytes.append(&mut value_bytes);
Expand Down
2 changes: 1 addition & 1 deletion src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl DataValue {
LogicalType::Char(_) => {
// 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 != 0) {
let last_non_zero_index = match bytes.iter().rposition(|&x| x != b' ') {
Some(index) => index + 1,
None => 0,
};
Expand Down

0 comments on commit 9e35bf0

Please sign in to comment.