use nanoids for entity id generation #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change switches the id generation to use nanoids instead of sequential numbers, allowing more flexibility without much concern for overlap.
The code is from release
v0.2.0
of eth0net/nanoid-godot (MIT).Currently it is configured to use 9 characters with a 64 character URL-safe alphabet, but this can be changed without an issue.
Tests have been updated to account for this change, including a hacky way of switching out the singleton Pandora backend for one of the tests due to restrictions around singletons.
There is no limitations placed on the contents of the ids in the code, only in the generator, meaning all the old sequential ids will continue to work. Perhaps some additional logic would be useful to migrate them though, as it would be safer going forward.
Any work done on the migration should take into account the possibility of being able to regenerate ids to change their length or alphabet, rather than just migrating from sequential to nanoid. This may be useful for forks of projects using Pandora or in other cases where people need to regenerate some or all of their ids.
Addressed issues
None
Screenshots