Repository navigation
Conversation
In PostgreSQL's text array serialization format, an unquoted `NULL` element represents SQL NULL, whereas a quoted `"NULL"` element represents the literal four-character string `"NULL"`. Previously, the text array decoder unquoted the element text before checking `if value == "NULL"`, erroneously decoding string `"NULL"` into `None` (SQL NULL) and causing silent data loss. This patch tracks whether the parsed element was surrounded by quotes (`was_quoted`) so that only unquoted `NULL` tokens are treated as SQL NULL. Closes transact-rs#4452
abonander
requested changes
Oct 27, 2026
abonander
left a comment
Collaborator
There was a problem hiding this comment.
cargo fmt needs to be run, otherwise LGTM.
Author
|
Ran |
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.
Does your PR solve an issue?
closes #4452
Is this a breaking change?
No. This is a bug fix for silent data loss when decoding PostgreSQL text arrays containing the literal string
"NULL".Description
In PostgreSQL's text array serialization format, an unquoted
NULLelement represents SQL NULL, whereas a quoted"NULL"element represents the literal string"NULL":Previously,
sqlx-postgres/src/types/array.rsunquoted the element text before checkingif value == "NULL", erroneously decoding the string"NULL"intoNone(SQL NULL) instead ofSome("NULL").This patch tracks whether the parsed element was enclosed in quotes (
was_quoted) so that only unquotedNULLtokens are mapped toNone.Includes unit tests verifying both
Vec<Option<String>>andVec<String>insqlx-postgres/src/types/array.rsand integration coverage intests/postgres/types.rs.