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

datatype.number does not produce random number when min = max + precision #329

Closed
pkuczynski opened this issue Jan 28, 2022 · 5 comments · Fixed by #664
Closed

datatype.number does not produce random number when min = max + precision #329

pkuczynski opened this issue Jan 28, 2022 · 5 comments · Fixed by #664
Assignees
Labels
c: bug Something isn't working p: 1-normal Nothing urgent

Comments

@pkuczynski
Copy link
Member

Describe the bug

faker.datatype.number returns always the same value =max+precision, when min = max + precision

Reproduction

faker.datatype.number({ min: 100000 })
// 100000 - on every run

Additional Info

A check ensuring max is reasonably larger then min is missing...

@pkuczynski pkuczynski added s: pending triage Pending Triage c: bug Something isn't working labels Jan 28, 2022
@github-actions github-actions bot removed the s: pending triage Pending Triage label Jan 28, 2022
@Shinigami92 Shinigami92 added this to the v6.1 - First bugfixes milestone Jan 28, 2022
@luciferreeves
Copy link
Contributor

luciferreeves commented Jan 28, 2022

The problem lies on this line:

// src/datatype.ts > number(...) {...}

if (typeof options.max === 'undefined') {
    options.max = 99999;
}

Since options.min is already defined before we reach this line, we can change the implementation to this:

if (typeof options.max === 'undefined') {
    options.max = options.min + 99999;
}

And it should be good enough, I hope.

@pkuczynski
Copy link
Member Author

I know where is the problem :) I would normally provide a PR, but @Shinigami92 asked not to do anything until we go to 6.1. so I just created this issue...

@import-brain import-brain moved this to Todo in Faker Roadmap Feb 7, 2022
@Shinigami92
Copy link
Member

@pkuczynski We are working on v6.1. Would you like to tackle this? Or is it free to be grabbed by someone else?

@Shinigami92 Shinigami92 added the p: 1-normal Nothing urgent label Mar 23, 2022
@pkuczynski
Copy link
Member Author

Yeah, let me have a look now :)

@pkuczynski
Copy link
Member Author

Yeah, let me have a look now :)

Done in #664

@Shinigami92 Shinigami92 moved this from Todo to In Progress in Faker Roadmap Mar 24, 2022
Repository owner moved this from In Progress to Done in Faker Roadmap Mar 31, 2022
@ST-DDT ST-DDT removed this from Faker Roadmap Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants