Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: MySQL2 binary/varbinary types are incorrectly typed as strings instead of buffers #1188

Open
tslater opened this issue Sep 7, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@tslater
Copy link

tslater commented Sep 7, 2023

What version of drizzle-orm are you using?

0.28.5

What version of drizzle-kit are you using?

0.19.13

Describe the Bug

The mysql2 library parses binary & varbinary columns as Buffer.

They also automatically convert Buffers to hex strings, so passing those in to a query is escaped correctly.

Expected behavior

The type should be Buffer

Environment & setup

Generally

@tslater tslater added the bug Something isn't working label Sep 7, 2023
@tslater
Copy link
Author

tslater commented Sep 7, 2023

There was a pull request for this, but it has been closed due to complications between the planetscale and mysql2 adapters differing in terms of behavior:
#425

@algora-pbc
Copy link

💎 $200 bounty created by @tslater
👉 To claim this bounty, submit your pull request on Algora
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to drizzle-team/drizzle-orm!

@ologbonowiwi
Copy link

There's anyone already working on it?

I would like to help with it 😄

@tslater
Copy link
Author

tslater commented Sep 15, 2023

@ologbonowiwi Do you think you can pound through it quickly? I thought there was someone on here that said they wanted to, but I only see it in my email and not here. I wonder if it was deleted? I say go for it since it's been a week and no sign of them.

@ologbonowiwi
Copy link

I'm not sure @tslater.

I want to help but I don't know the project internals, so it'll be quite a challenge.

/attempt #1188

@ryanagillie
Copy link

ryanagillie commented Sep 19, 2023

@ologbonowiwi Hey! Thanks for sending me a DM on linkedin, I have my github completely muted and missed this.

I had tried getting it working but as in the PR, the mysql2 package (which is API compliant with the mysql package) parses binary and varbinary columns as Buffer while the @planetscale/database parses them as string | null.

I tried playing around to get it to work but ran into the issue that they both rely on the drizzle-orm/mysql-core sub-package (specifically the MySqlVarBinaryBuilderInitial). So changing the column definitions in one changes them in the other.

Life got busy and I converted to neon / postgress in my projects so I abandoned it.

Hope I could help, but this is pretty complicated and I'm not sure how to fix it. Let me know if you need anything else!

@ologbonowiwi
Copy link

Thanks for the clarification, @ryanagillie; only this comment helped a lot!

@ologbonowiwi
Copy link

The work on #1253 from my side is mostly done, this was the last update from @AndriiSherman on the discord thread.

image

Posting it here so we have the issue updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants