question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need a VARBINARY data type

See original GitHub issue

Sequelize currently doesn’t have a native string type that maps to an easily indexable VARBINARY in MySQL.

This is going to be a growing issue due to utf8mb4, under which the practice (that Sequelize also uses) of using VARCHAR(255) and InnoDB leads to indexes that are too large and cause CREATE TABLE to fail. With the new charset limitations, some columns will simply use a smaller index size; while others will be better off using a VARBINARY. For example, a sorted title index would likely be better off with a utf8mb4 index with a smaller size and a column storing the string identifier for a facebook/google/etc… account would be best off switching to a VARBINARY.

Note that STRING.BINARY will not work because that is for VARCHAR(255) BINARY which still use utf8mb4 and just use the _bin charset, they still use 4 bytes per character in indexes. Also BLOB makes for indexing issues, our inherent problem.

Naming ideas: STRING.RAW, VARBINARY

This should be relatively simple for someone who knows how data-types.js works to do. I can’t submit a patch set since I don’t understand enough about how the oids in the pg data-types.js file works.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
castarcocommented, Aug 12, 2016

Not only VARBINARY is needed, we need support for BINARY too.

Both options are far different from VARCHAR and CHAR, since BINARYis treated like an opaque vale, without the risk of encoding-issues.

At our company we’re using BINARY to encode our IDs, which are similar to UUIDs… but not the same. And we’re using a BINARY column to decrease memory usage.

1reaction
vmadmancommented, Sep 5, 2017

+1

I will look into adding it, if I can, but I suspect that it is more complicated than meets the eye… given that no one has taken this on already.

Edit:

After a small amount of investigating, it really doesn’t seem all that important, since Sequelize doesn’t do much with the type, anyway. There might be some advanced reasons to need the data type, but, on the surface, it doesn’t seem like it would give you very much.

I found this…

Read more comments on GitHub >

github_iconTop Results From Across the Web

binary and varbinary (Transact-SQL) - Microsoft Learn
Variable -length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes....
Read more >
SQL VARBINARY Data Type - Dofactory
The VARBINARY data type holds variable-length binary data. Use this type when the data is expected to vary in size. The maximum size...
Read more >
Binary and VarBinary Data Types in SQL Server
VarBinary is a variable width data type. The syntax for declaring Binary variable is varbinary(n) , where n defines the maximum size in...
Read more >
Binary Data Types (BINARY and VARBINARY) - Vertica
BINARY: A fixed-width string of length bytes, where the number of bytes is declared as an optional specifier to the type. · VARBINARY:...
Read more >
VARBINARY - MariaDB Knowledge Base
The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings. M represents the maximum...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found