Repository navigation
Feature/binary UUID - #10290
Feature/binary UUID#10290bradennapier wants to merge 13 commits into
Conversation
Codecov Report
Continue to review full report at Codecov.
|
| * | ||
| * @namespace DataTypes.BINARYUUID | ||
| */ | ||
| function BINARYUUID() { |
There was a problem hiding this comment.
@sushantdhiman I was wondering if you want to enforce these to be classes (and be called with new) in v5?
There was a problem hiding this comment.
I'd prefer it! Was just following what I saw previous!
| */ | ||
| function UUIDV1() { | ||
| if (!(this instanceof UUIDV1)) return new UUIDV1(); | ||
| function UUIDV1(binary) { |
There was a problem hiding this comment.
I suggest you make this parameter an object instead, avoid future breaking changes if we wish to add more optional parameters.
| const operators = require('./operators'); | ||
| const operatorsArray = _.values(operators); | ||
|
|
||
| const toBinaryUUID = require('binary-uuid').toBinaryUUID; |
There was a problem hiding this comment.
Is it really worth it adding yet another dependency for a very niche data type like this?
Wouldn't it make more sense to split special datatypes and dialects into smaller packages?
There was a problem hiding this comment.
The dependency was written for this PR specifically - just left it as its own package as it was small and could be used in other places easily. It's only a few lines of code really! I implemented as its own package as well:
However I do think having this native to sequelize is a good idea as using uuid's the wrong way are pretty damaging and based on other comments and stack overflow - a TON of people are implementing them in the worst way possible (using v4 as primary key and not shuffling their v1's when they use the right style).
|
For now let's keep this as a separate package @bradennapier , if there is more demand we will add its support to Sequelize |
|
@sushantdhiman Yes, there is demand. Thanks! |
|
I'm surprised this was called a niche use case. This package implements UUIDs in the way they're supposed to be implemented when used for primary keys, and UUIDs as primary keys are certainly not niche or uncommon. Another +1 here, this would be invaluable for us. |
|
In the meantime, the package does work well :) - but agreed it should be built in. |
|
+1 for me too, I would like to see this included! |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
#10265 #9271 #4997
This starts to implement a binary uuid type. It is meant to open the general discussion around what may be missing. I have implemented a working package as a module here to give a better idea: https://github.com/odo-network/sequelize-binary-uuid
The benefit is fairly massive (@see: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/)
This PR implements the
UUIDV1shuffling as recommended by above as well as mysql team directly to greatly improve performance while indexing UUIDs.Example
Open Questions
DataTypes.UUID.BINARYI could not make it work when trying to use
UUID.BINARYas it was breaking when going to dialects and not passing options on, among other things... probably makes the most sense there but way too many side effects so I changed to usingBINARYUUIDtype.Virtual / Transformed Field
In https://github.com/odo-network/sequelize-binary-uuid it also provides a virtual representation of the field in a fairly straight-forward way. I wasn't sure the best way to do something similar here.
https://github.com/odo-network/sequelize-binary-uuid#using-withbinaryuuid-preset-recommended
https://github.com/odo-network/sequelize-binary-uuid#creating-a-uuid-virtual-field
Specifically since the
uuidv1is transformed to binary - there should be a simple and easy way to view the field as its non-binary form.v5 breaks
X'${hex}'handlingIt would appear that v5 breaks the handling of anything using
X'...- I haven't tested but as far as I can tell this would break a few areas such asBLOBbut I may be wrong. In the end it seems that stringify just doesn't make sense to use.I was hoping it would work though as it makes the LOGGING much more helpful than just putting up question marks like it does now.