Bug: Record IDs generated with rand() ulid() uuid() in custom functions generate same value #2260
Closed
2 tasks done
Labels
Milestone
Describe the bug
When using a random record id function to create a new record e.g.
CREATE thing:ulid()
in a custom function the value generated is the same on each function call. This results in a duplicate key error on subsequent calls.Steps to reproduce
Define a function that creates records using a random function. In this example using
ulid()
:Call the function wrapped in a transaction:
The first call of the function will succeed. But any subsequent calls will produce an error:
Database record
thing:01H5AB5KR7P6SCN9CV2E3B83AKalready exists
This is the same behavior with the other random functions
rand()
anduuid()
. I have only experienced this in custom functions.A workaround to avoid this is to use the
type::thing()
function to create the record id in the custom function. For example.Expected behaviour
I expect a new random record id to be generated when using rand() or ulid() or uuid() record id shortcuts to create records in a custom function.
SurrealDB version
1.0.0-beta.9+20230402.5eafebd for linux on x86_64
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: