Skip to content

fix: Scan accepts text-encoded ULIDs in []byte - #134

Merged
tsenart merged 1 commit into
oklog:mainfrom
sonnemusk:fix/scan-text-as-bytes
Jul 23, 2026
Merged

fix: Scan accepts text-encoded ULIDs in []byte#134
tsenart merged 1 commit into
oklog:mainfrom
sonnemusk:fix/scan-text-as-bytes

Conversation

@sonnemusk

Copy link
Copy Markdown
Contributor

Summary

(*ULID).Scan treated every []byte as binary. Drivers commonly hand text columns back as []byte, so scanning a 26-character encoded ULID failed with ErrDataSize.

Accept both lengths:

  • 16 → binary
  • 26 → text encoding

Test plan

  • go test -run TestScan (includes text-as-bytes case)

database/sql drivers often return text/varchar as []byte. Scan only
tried UnmarshalBinary, so a 26-char encoded ULID failed with
ErrDataSize. Accept binary (16) and text (26) lengths.

@tsenart tsenart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed commit 5c57a8d. No blocking findings. Verified TestScan (100 repetitions), go test -race ./..., go vet ./..., and staticcheck ./... locally; all passed.

@tsenart
tsenart merged commit 75921a7 into oklog:main Jul 23, 2026
4 checks passed
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.

2 participants