Skip to content

Conversation

@amureki
Copy link
Member

@amureki amureki commented Jul 25, 2025

Describe the change
A draft attempt to address #61

PR Checklist

  • Change is covered with tests
  • CHANGELOG.md is updated if needed

@amureki amureki self-assigned this Jul 25, 2025
Copy link
Member

@berinhard berinhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea of defining per-field generators methods. I'm only leaving the comment since this is on draft, but I think it's a good path to follow.

Comment on lines +98 to +102
from django.db.backends.base.operations import BaseDatabaseOperations

return BaseDatabaseOperations.integer_field_ranges.get(
field_name, (-MAX_INT, MAX_INT)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding!

Comment on lines +80 to +92
warnings.warn(
"gen_integer() may cause overflow errors with Django integer fields due to "
"large default MAX_INT value. Consider using field-specific generators instead:\n"
"- gen_positive_small_integer() for PositiveSmallIntegerField\n"
"- gen_small_integer() for SmallIntegerField\n"
"- gen_regular_integer() for IntegerField\n"
"- gen_positive_integer() for PositiveIntegerField\n"
"- gen_big_integer() for BigIntegerField\n"
"- gen_positive_big_integer() for PositiveBigIntegerField\n"
"See model_bakery.random_gen documentation for more details.",
DeprecationWarning,
stacklevel=2,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch with the warning 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants