We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 245a3ae commit 45429b1Copy full SHA for 45429b1
sqlx-core/src/postgres/types/int.rs
@@ -31,7 +31,12 @@ impl Encode<'_, Postgres> for i8 {
31
impl Decode<'_, Postgres> for i8 {
32
fn decode(value: PgValueRef<'_>) -> Result<Self, BoxDynError> {
33
// note: in the TEXT encoding, a value of "0" here is encoded as an empty string
34
- let bytes: [u8; 1] = value.as_bytes()?[..1].try_into().unwrap_or_default();
+ let bytes = value.as_bytes()?;
35
+ let bytes: [u8; 1] = bytes
36
+ .get(..1)
37
+ .unwrap_or(&[0])
38
+ .try_into()
39
+ .unwrap_or_default();
40
Ok(i8::from_be_bytes(bytes))
41
}
42
0 commit comments