You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dialect: mysqlFor issues and PRs. Things that involve MySQL (and do not involve all dialects).good first issueFor issues. An issue that is a good choice for first-time contributors.stale
UUIDs are 128 bit integers, which means they should fit into BINARY(16), but sequelize generates CHAR(36) strings instead-- a rather huge increase in size.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
I began working on this issue and the database is already using the BINARY(16) format, but it shows the binary format to the user. How can I apply a function to the field before returning it?
@Rudedog9d see that #10290 already implements that natively without the need. In addition you can utilize it without the need for MySQL / MySQL 8 by utilizing the libraries i built for them:
I originally used the BIN_TO_UUID function as mentioned but it would have a strong dependency on instance type/version and it required multiple round-trips since it required calling the fn to get a uuid then creating the row after. Since async wasn't possible in getters it required the use of hooks instead which was a problem.
The package sequelize-binary-uuid provides the optimum and easiest solution. I didn't pursue the PR further because it seemed it made most sense this way. It also has the benefit of building a virtual key for you which makes it much easier to work with the binary uuid itself since you always can reference the string representation.
@omidkrad well the good news is my company is switching to 100% typescript so... I’d imagine it will be supported soon :)
They just decided to wait to see if there’s enough demand for binary uuid in this way so make sure you indicate your support for it officially as well :)
@omidkrad well the good news is my company is switching to 100% typescript so... I’d imagine it will be supported soon :)
They just decided to wait to see if there’s enough demand for binary uuid in this way so make sure you indicate your support for it officially as well :)
Any developments on using this with sequelize-typescript?
@spencerwasden
Any developments on using this with sequelize-typescript?
It shouldn't be difficult to use the package with sequelize-typescript - you'd need to make the typings for now but it would be relatively straight forward/simple.
Actually it couldn't have been 100% typed until the recent 4.1 launch which would allow adding custom-named keys to the types but I am not sure my bandwidth would have me updating that any time soon...
Ideally sequelize would add this for official support :-P
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
dialect: mysqlFor issues and PRs. Things that involve MySQL (and do not involve all dialects).good first issueFor issues. An issue that is a good choice for first-time contributors.stale
Activity
nathanmarks commentedon Dec 16, 2015
For reference:
http://iops.io/blog/storing-billions-uuid-fields-mysql-innodb/
http://mysql.rjweb.org/doc.php/uuid
mickhansen commentedon Dec 16, 2015
Assuming this is not a breaking change it shouldn't be too tricky to change: https://github.com/sequelize/sequelize/blob/master/lib/dialects/mysql/data-types.js#L45
stale commentedon Jun 29, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
rafaelalmeidatk commentedon Mar 20, 2018
I began working on this issue and the database is already using the
BINARY(16)format, but it shows the binary format to the user. How can I apply a function to the field before returning it?omidkrad commentedon Apr 5, 2018
Maybe Sequelize should support
UUID.BINARYdata type.See related issue: #9271
bradennapier commentedon Dec 11, 2018
Note that in #9271 I posted my working solution to accomplish this.
Rudedog9d commentedon Jan 15, 2019
@rafaelalmeidatk Could you leverage
BIN_TO_UUIDto convert the bytes to UUID?Check out this article for more: https://mysqlserverteam.com/mysql-8-0-uuid-support/
bradennapier commentedon Jan 15, 2019
@Rudedog9d see that #10290 already implements that natively without the need. In addition you can utilize it without the need for MySQL / MySQL 8 by utilizing the libraries i built for them:
https://github.com/odo-network/sequelize-binary-uuid
https://github.com/odo-network/binary-uuid
which implement an identical effect.
I originally used the
BIN_TO_UUIDfunction as mentioned but it would have a strong dependency on instance type/version and it required multiple round-trips since it required calling the fn to get a uuid then creating the row after. Since async wasn't possible in getters it required the use of hooks instead which was a problem.The package
sequelize-binary-uuidprovides the optimum and easiest solution. I didn't pursue the PR further because it seemed it made most sense this way. It also has the benefit of building a virtual key for you which makes it much easier to work with the binary uuid itself since you always can reference the string representation.omidkrad commentedon Jan 18, 2019
@bradennapier thanks, this is great. I wished I could use sequelize-binary-uuid with sequelize-typescript. If this gets added to sequelize, there's a good chance that they also add it to sequelize-typescript.
bradennapier commentedon Jan 18, 2019
@omidkrad well the good news is my company is switching to 100% typescript so... I’d imagine it will be supported soon :)
They just decided to wait to see if there’s enough demand for binary uuid in this way so make sure you indicate your support for it officially as well :)
spencerwasden commentedon Nov 29, 2020
@bradennapier
Any developments on using this with sequelize-typescript?
bradennapier commentedon Dec 2, 2020
It shouldn't be difficult to use the package with sequelize-typescript - you'd need to make the typings for now but it would be relatively straight forward/simple.
Actually it couldn't have been 100% typed until the recent 4.1 launch which would allow adding custom-named keys to the types but I am not sure my bandwidth would have me updating that any time soon...
Ideally sequelize would add this for official support :-P
github-actions commentedon Nov 16, 2021
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂