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

Configurable global default max int value #3338

Open
karlismelderis-mckinsey opened this issue Dec 19, 2024 · 2 comments
Open

Configurable global default max int value #3338

karlismelderis-mckinsey opened this issue Dec 19, 2024 · 2 comments
Labels
c: feature Request for new feature has workaround Workaround provided or linked m: number Something is referring to the number module p: 1-normal Nothing urgent s: awaiting more info Additional information are requested s: waiting for user interest Waiting for more users interested in this feature
Milestone

Comments

@karlismelderis-mckinsey

Clear and concise description of the problem

currently number.int() upper boundary is Number.MAX_SAFE_INTEGER
such values don't fit in postgres int (max 2147483647)

in our case it's acceptable to generate values with {max: 2147483647} but because a lot of faker data is auto-generated it's not easy to add max value everywhere and where it's possible it leads to repeating same configuration for .int()

Would be great if it would be possible to set global FAKER_MAX_INTEGER value

Suggested solution

add a global configuration option to override Number.MAX_SAFE_INTEGER

Alternative

No response

Additional context

No response

@karlismelderis-mckinsey karlismelderis-mckinsey added c: feature Request for new feature s: pending triage Pending Triage s: waiting for user interest Waiting for more users interested in this feature labels Dec 19, 2024
Copy link
Contributor

Thank you for your feature proposal.

We marked it as "waiting for user interest" for now to gather some feedback from our community:

  • If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
  • If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.

We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.

We will start the implementation based on:

  • the number of votes (:+1:) and comments
  • the relevance for the ecosystem
  • availability of alternatives and workarounds
  • and the complexity of the requested feature

We do this because:

  • There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
  • Every feature we add to faker has "costs" associated to it:
    • initial costs: design, implementation, reviews, documentation
    • running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors

View more issues which are waiting for user interest

@ST-DDT ST-DDT added this to the vFuture milestone Dec 19, 2024
@ST-DDT ST-DDT added the m: number Something is referring to the number module label Dec 19, 2024
@ST-DDT
Copy link
Member

ST-DDT commented Dec 19, 2024

faker.number.int()

in our case it's acceptable to generate values with {max: 2147483647} but because a lot of faker data is auto-generated it's not easy to add max value everywhere and where it's possible it leads to repeating same configuration for .int()

Is you feature request for faker.number.int specifically or are you referring to other impacted methods as well?

As a workaround, you could use a helper method:

function uint31() {
   return faker.number.int({max: 2147483647});
}

If you look at the method name, then you might already notice, that this covers a very specific use case.
What if you want the entire sint32 range (-2^31 - 2^31 - 1)? Then you would need a FAKER_MIN_INTEGER as well.
What about floats? All the other options in the other methods.

I agree that FAKER_MAX_INTEGER is more likely to be used then most other options, but it is fairly easy to write your own method/workaround to achieve the expected range. Also I assume, that it is more or equally likely to need more than one range, than just uint31.

If we are going to implement it, I would like to have it via config option (v10) rather than an actual global const.

@ST-DDT ST-DDT added p: 1-normal Nothing urgent s: awaiting more info Additional information are requested has workaround Workaround provided or linked and removed s: pending triage Pending Triage labels Dec 19, 2024
@ST-DDT ST-DDT changed the title Global int max (support PG int range) Configurable global default max int value Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature has workaround Workaround provided or linked m: number Something is referring to the number module p: 1-normal Nothing urgent s: awaiting more info Additional information are requested s: waiting for user interest Waiting for more users interested in this feature
Projects
None yet
Development

No branches or pull requests

2 participants