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

Support for native UUID types #214

Open
faultyserver opened this issue Sep 22, 2018 · 0 comments
Open

Support for native UUID types #214

faultyserver opened this issue Sep 22, 2018 · 0 comments

Comments

@faultyserver
Copy link
Contributor

(sorry for making a bunch of new issues and not doing anything to solve them yet. I'll get there, I promise)

UUIDs are commonly used as primary keys in large database tables, providing a dense, globally-unique, and opaque identification system. Currently, Crecto "supports" UUID values by treating them like normal strings.

However, a large advantage of UUIDs is that they are simple 128-bit values that can be stored and utilized in their binary form. This can be noticeably more performant than the string representation, especially as tales grow in size.

Crystal's UUID type already uses the binary data for comparison, so implementing this seems like it could just be a matter of adding it as a valid field type and constructing the type properly.

In terms of database support, Postgres has had native support for UUID types since at least 8.3, and MySQL introduced the datatype in 8.0, but SQLite does not natively support them as a datatype.

In the last case, where the database does not support the UUID type natively, I would imagine Crecto could just fallback to just storing the data either as a 16-byte binary blob or integer type, either of which would still provide a benefit over storing them as strings.

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

1 participant