Skip to content
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

uuid primary key as binary(16) in mysql #683

Open
rakesh410 opened this issue Mar 31, 2015 · 4 comments
Open

uuid primary key as binary(16) in mysql #683

rakesh410 opened this issue Mar 31, 2015 · 4 comments

Comments

@rakesh410
Copy link

I want to use uuid as primary key but stored as binary 16 in mysql db. is there anyway to apply hook on insert and apply hex/unhex on the uuid with dashes removed?

@mde
Copy link
Contributor

mde commented Apr 4, 2015

I'm not entirely clear what you're trying to do here. If it's essentially string keys, you could simply use string UUIDs, and generate your own via some auto-increment function, then save them as custom UUID strings on each item.

This is just a workaround, but I'm not entirely clearly why you would want to do this.

@rakesh410
Copy link
Author

let me explain:

  1. I want to use UUID as primary key
  2. In geddy I created demo app using tutorial and observed that it created primary key as string and database store was varchar(255), where it was storing UUID as string.
  3. I want change this database store to binary(16) where UUID will not be stored as string but as a 16bit HEX number - strip off "-" and open close braces from UUID and convert that string to binary coded hex number while storing, reverse should happen while retrieving primary key.

Is this possible?

Thanks

@der-On
Copy link
Contributor

der-On commented Apr 15, 2015

I did this before in PHP. It's tricky because UUIDs contain dashes which need to be removed before storage and added after read. It is indeed a lot faster and saves disk space.

Currently this is not possible but we welcome PRs.

@der-On
Copy link
Contributor

der-On commented Apr 15, 2015

You can take a look at how I did it in PHP: https://github.com/der-On/PHP-FluxAPI-Plugins-Core/blob/master/Storage/MySql.php#L805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants