dynamodb-onetable: Built in UUID function does not generate real UUIDs

Describe the bug The built in UUID function just generates a random string. It’s not a UUID, and doesn’t comply with the spec.

Expected behavior It should be a real UUID, or be renamed to just randomId

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS
  • Node Version
  • OneTable Version

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (11 by maintainers)

Most upvoted comments

Sorry I haven’t been focussed on this for a bit. Thanks for solving this, I just caught up on the 2.3 release notes and I think the new API for this is much clearer!

But Table.setMakeID is not declared in Table in Table.d.ts 😦

If you don’t want to have uuid dependency (and I salute this effort!), I’d suggest dropping the uuid option altogether from the library. ulid is there and is enough.

If one using this library absolutely needs the ids to be uuid in the proper definition of what uuid is documented to be, they can bring it in via Table.setMakeID

If the library itself needs to generate ids that are not ulid, then provide a suitable implementation and not call it uuid.

You can add your own ksuid via the table constructor by setting the params.uuid to a function of your choosing.

Thanks for considering this. After updating to 2.1.1 I had the problem by myself. Suddenly a create was not working anymore. After updating the validation regex it worked again, of course.

Hi @mobsense, I would consider this behaviour a breaking change in the v2.1.1 release. Because everyone who used uuids with the matching validation from your docs before (uuid: /^[0-9A-F]{32}$/i,), will now get a validation error on creating new items, as you also added hyphens to it (see c949aa3c2fd591d6a1be29d6ec75c72284897fde and bd67bb4b7ceaaac4fbf85c3fe1217a35ab90578d).