Support auto generate UUID for non pk field
See original GitHub issueFirst, Thank you for support nice software 😃 I find that UUIDField only auto generate UUID4 only that field is primary key. How about support auto generate UUID key for non pk field?
Maybe we can use like below
uid = fields.UUIDField(auto_generate=True) # default : False
Also, I’m not good at orm and database well. I want to hear about other’s opinions. I really appreciate if anyone answer to me! Thank you 👍
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to Auto generate UUID value for non-primary key using JPA
I have a non-primary key of type UUID which I want to auto generate on call of save method. I annotated the attribute...
Read more >Auto-generated primary keys: UUID, serial or identity column?
This article explores the old question what to use for autogenerated primary keys: UUID, serial or identity column?
Read more >How to generate UUIDs as primary keys with Hibernate
Generating UUIDs using JPA 3.1 Since JPA 3.1, you can annotate a primary key attribute with @GeneratedValue and set the strategy to GenerationType....
Read more >Enable <generator> tag for non primary key columns that are ...
Our current datamodel has a UUID char 32 as the primary key and ID column which is a sequence for Oracle and an...
Read more >SQL Primary Key - UUID or Auto Increment Integer / Serial?
For database like MySQL, Oracle, which uses clustered primary key, version 4 randomly generated UUID will hurt insertion performance if used as ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi!
Actually, for pk uuid fields generation is done inside of Tortoise just like that:
So, if you wanna same behaviour for non-pk uuid field you just have to do it like that:
Yes, I have been having to do many support queries where the docs either had something missing, or was hard to find. We need doc guidelines.