Skip to content

fix: treat empty string/bytes as NULL in NullUUID.Scan - #222

Closed
sonnemusk wants to merge 1 commit into
google:masterfrom
sonnemusk:fix/nulluuid-scan-empty-string
Closed

fix: treat empty string/bytes as NULL in NullUUID.Scan#222
sonnemusk wants to merge 1 commit into
google:masterfrom
sonnemusk:fix/nulluuid-scan-empty-string

Conversation

@sonnemusk

Copy link
Copy Markdown

Summary

`NullUUID.Scan("")` (and empty `[]byte`) previously set `Valid=true` with a Nil UUID because `UUID.Scan` treats empty as success without error.

Empty database values should behave like SQL NULL: `Valid=false`, `UUID=Nil`.

Fixes #109.

Test plan

  • `go test . -run TestNullUUID`

UUID.Scan("") succeeds with a Nil UUID, so NullUUID.Scan previously set
Valid=true for empty DB values. Treat empty string and empty []byte as
SQL NULL (Valid=false), matching NullUUID.Scan(nil). Fixes #109.
@sonnemusk
sonnemusk requested a review from a team as a code owner July 22, 2026 07:31
@google-cla

google-cla Bot commented Jul 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@sonnemusk
sonnemusk force-pushed the fix/nulluuid-scan-empty-string branch from 57a2a62 to 203a75e Compare July 22, 2026 07:55
@sonnemusk

Copy link
Copy Markdown
Author

Closing this PR as low-signal noise after a quality pass on open contributions. Sorry for the distraction — focusing on fewer, higher-impact fixes going forward.

@sonnemusk sonnemusk closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullUUID Scan method returns valid true on empty string

1 participant