Skip to content
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

Random number is actually floating value #1589

Open
janpio opened this issue Apr 7, 2021 · 0 comments
Open

Random number is actually floating value #1589

janpio opened this issue Apr 7, 2021 · 0 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug.

Comments

@janpio
Copy link
Member

janpio commented Apr 7, 2021

Multiple projects here use the following code to generate a random ID:

const rand = Math.random().toString()

https://github.com/prisma/e2e-tests/search?q=const+rand+%3D+Math.random%28%29.toString%28%29

As Math.random() generates a value between 0 and 1, this returnss a value like 0.7287719726956376. That is probably not expected and wanted.

Some databases probably just cast that value, or we are not using it further.

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. labels Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug.
Development

No branches or pull requests

1 participant