Skip to content

Char and varchar can return Buffer #1071

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

Closed
LinusU opened this issue Apr 30, 2015 · 4 comments
Closed

Char and varchar can return Buffer #1071

LinusU opened this issue Apr 30, 2015 · 4 comments
Assignees
Labels

Comments

@LinusU
Copy link
Contributor

LinusU commented Apr 30, 2015

I don't see it documented but both CHAR and VARCHAR can return a Buffer if they have CHARACTER SET binary set. Is this intentional?

I opted for CHAR(60) CHARACTER SET binary instead of BINARY(60) specifically so that I would get strings instead. My use case is this: I'm storing the hash from bcrypt which is 60 characters ascii. I don't want the database to assume anything about the content and I don't want it doing case-insensitive matching, so therefor I choose CHARACTER SET binary.

Should I be rethinking this or should the library be updated?

@dougwilson
Copy link
Member

Yes, this is intentional, unfortunately. You can always define your our typeCast to override this, but when I created the same type of column for my own stuff, I have always used the following: CHARACTER SET ascii COLLATE ascii_bin.

@LinusU
Copy link
Contributor Author

LinusU commented Apr 30, 2015

Thanks, I've updated my database to that. Do you think that it would be relevant to add this to the readme? Feel free to close the issue otherwise...

@dougwilson
Copy link
Member

Yes, I agree docs should note this.

@dougwilson dougwilson added the docs label May 4, 2015
@dougwilson dougwilson self-assigned this May 4, 2015
@LinusU
Copy link
Contributor Author

LinusU commented May 5, 2015

👍 nice!

seangarner pushed a commit to seangarner/node-mysql that referenced this issue May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants