Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Fix long VARCHAR and short STRING issues#4

Open
brunograsselli wants to merge 2 commits intoSponsorPay:masterfrom
brunograsselli:long_chars_fix
Open

Fix long VARCHAR and short STRING issues#4
brunograsselli wants to merge 2 commits intoSponsorPay:masterfrom
brunograsselli:long_chars_fix

Conversation

@brunograsselli
Copy link
Copy Markdown
Contributor

The first issue happened with long VARCHAR fields. If the VARCHAR had
more than 255 characters MYSQL uses 2 (not only 1) bytes to store some
information at the beginning of the string.

The previous code was aware of it but it checked it using the size of
the string, not the information from the metadata of the field. In some
cases it didn't work.

After changing that I've introduced a new bug. There is a STRING type which
the metadata is not the size of the field. You have to check inside this
integer to find the size of the field.

I fixed now how to get the size of the STRING field.

The first issue happened with long VARCHAR fields. If the VARCHAR had
more than 255 characters MYSQL uses 2 (not only 1) bytes to store some
information at the beginning of the string.

The previous code was aware of it but it checked it using the size of
the string, not the information from the metadata of the field. In some
cases it didn't work.

After changing that I've introduced a new bug. There is a STRING type which
the metadata is not the size of the field. You have to check inside this
integer to find the size of the field.

I fixed now how to get the size of the STRING field.
@cswilliams
Copy link
Copy Markdown

+1, this fixed a bug I was running into where varchar(255) columns with 256 characters were getting the first character inadvertently chopped off.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants