Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sqlx-postgres/src/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ where
let mut buf = value.as_bytes()?;

if value.format() == PgValueFormat::Binary && value.type_info == PgTypeInfo::JSONB {
assert_eq!(
buf[0], 1,
"unsupported JSONB format version {}; please open an issue",
buf[0]
);
// Check JSONB version byte - PostgreSQL currently only supports version 1
if buf[0] != 1 {
return Err(
format!("unsupported JSONB format version {} (expected 1)", buf[0]).into(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
format!("unsupported JSONB format version {} (expected 1)", buf[0]).into(),
format!("unsupported JSONB format version {} (expected 1) or incorrect type/corrupt data", buf[0]).into(),

As long as we're touching this, might as well cover the other possible cases.

);
}

buf = &buf[1..];
}
Expand Down