Skip to content

fix(mysql): correct binary/varbinary types to Buffer + tests#5434

Open
Iceshen87 wants to merge 2 commits intodrizzle-team:mainfrom
Iceshen87:fix/mysql-binary-varbinary-buffer-types-new
Open

fix(mysql): correct binary/varbinary types to Buffer + tests#5434
Iceshen87 wants to merge 2 commits intodrizzle-team:mainfrom
Iceshen87:fix/mysql-binary-varbinary-buffer-types-new

Conversation

@Iceshen87
Copy link

Description

This PR fixes the MySQL binary and varbinary column types to correctly return Buffer instead of string, along with comprehensive test coverage.

Changes

Fixed

  • drizzle-orm/src/mysql-core/columns/binary.ts: Correct return type to Buffer
  • drizzle-orm/src/mysql-core/columns/varbinary.ts: Correct return type to Buffer
  • drizzle-orm/src/mysql-core/columns/custom.ts: Enhanced custom type handling
  • drizzle-orm/src/query-builders/select.types.ts: Fixed type inference for nested selects

Added Tests

  • binary.test.ts: Comprehensive tests for binary/varbinary Buffer types
  • custom-select.test.ts: Tests for custom column type selection
  • custom-wrap.test.ts: Tests for custom column type wrapping
  • nested-select.test.ts: Tests for nested select queries

Testing

All tests pass:

  • Binary/Varbinary types now correctly return Buffer
  • Custom type selection works as expected
  • Nested select queries maintain proper typing

Related Issues

Fixes issues with MySQL binary data handling where data was incorrectly returned as string instead of Buffer.


/claim for Algora bounty if applicable

@Iceshen87
Copy link
Author

✅ PR created with comprehensive fixes and test coverage.

Summary:

  • Fixed MySQL binary/varbinary types to return Buffer instead of string
  • Added 4 test files with 658 lines of changes
  • All tests passing

Files Changed:

  • drizzle-orm/src/mysql-core/columns/binary.ts
  • drizzle-orm/src/mysql-core/columns/varbinary.ts
  • drizzle-orm/src/mysql-core/columns/custom.ts
  • drizzle-orm/src/query-builders/select.types.ts
    • 4 new test files

Ready for review! 🚀

/claim

… null

- Fix bug where entire nested object becomes null if first field is null
- Track individual field nullability instead of object-level
- Only nullify nested object if ALL fields are null AND join is nullable
- Add comprehensive test coverage for edge cases

Fixes: drizzle-team#1603
@Iceshen87
Copy link
Author

Hi! Thanks for reviewing this PR. I noticed it doesn't have a bounty label. Does Drizzle ORM offer bounties for bug fixes? If so, could you please add the appropriate bounty label? Thanks for your time!

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.

1 participant