Skip to content

Commit

Permalink
style: code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Mar 21, 2024
1 parent f30c4a8 commit f8152c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn encode_tuples<'a>(schema: &Schema, tuples: Vec<Tuple>) -> PgWireResult<QueryR
LogicalType::UBigint => encoder.encode_field(&value.u64().map(|v| v as i64)),
LogicalType::Float => encoder.encode_field(&value.float()),
LogicalType::Double => encoder.encode_field(&value.double()),
LogicalType::Varchar(_) => encoder.encode_field(&value.utf8()),
LogicalType::Char(_) | LogicalType::Varchar(_) => encoder.encode_field(&value.utf8()),
LogicalType::Date => encoder.encode_field(&value.date()),
LogicalType::DateTime => encoder.encode_field(&value.datetime()),
LogicalType::Decimal(_, _) => todo!(),
Expand Down
6 changes: 1 addition & 5 deletions src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,7 @@ impl DataValue {
DataValue::UInt64(v) => v.map(|v| v.encode_fixed_vec()),
DataValue::Utf8(v) => v.clone().map(|mut v| {
if let Some(LogicalType::Char(len)) = logical_type {
let difference = (len as usize).saturating_sub(v.len());

for _ in 0..difference {
v.push(' ')
}
v = format!("{:len$}", v, len = len as usize);
}
v.into_bytes()
}),
Expand Down

0 comments on commit f8152c3

Please sign in to comment.