-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add support for UUID as primary key #7
Comments
Hello @llulioscesar |
The uuid in pk is a best practice for large projects where your id can be generated not only in the database but also on the client side. It is not necessary to use id to keep order, it is not its responsibility. Also, easily predictable (ordered) id is an opportunity to hack your system very quickly and get access to protected data. No need for gen_random_uuid(), id generation should be done explicitly in code on go or somewhere else. The type should not be string but https://github.com/google/uuid. |
Currently, there seems to be limited support for using UUID as a primary key in models. When trying to use UUID with the primary tag, the following error occurs:
Example code that produces the error:
Expected behavior:
gen_random_uuid()
primary
tag with string/UUID fieldsPossible Solution:
Consider adding explicit support for UUID fields in the migrator, similar to how numeric primary keys are handled. This would be particularly useful for distributed systems where UUIDs are preferred over sequential IDs.
Additional context:
This feature would be beneficial for:
Environment:
korm version: v1.95.8
Go version: 1.22
Database: PostgreSQL
Would you be interested in contributions to implement this feature?
The text was updated successfully, but these errors were encountered: