Allow for integer values larger than 32-bits (#137)

* style: apply ignores to all migrations

* feat: support 64-bit integers

* doc: update changelog

* test: add test for bigger than 32-bit integer
This commit is contained in:
Mike 2021-12-18 19:29:38 -08:00 committed by GitHub
parent 6416477dad
commit ed7a808ee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 2 deletions

View file

@ -6,6 +6,8 @@ We follow [Semantic Versions](https://semver.org/) starting at the `0.14.0` rele
### Features
- Adds 64-bit support for `Value.value_int`
### Bug Fixes
### Misc

View file

@ -0,0 +1,17 @@
from django.db import migrations, models
class Migration(migrations.Migration):
"""Convert Value.value_int to BigInteger."""
dependencies = [
('eav', '0006_add_entity_uuid'),
]
operations = [
migrations.AlterField(
model_name='value',
name='value_int',
field=models.BigIntegerField(blank=True, null=True),
),
]

View file

@ -443,7 +443,7 @@ class Value(models.Model): # noqa: WPS110
value_csv = CSVField(blank=True, null=True)
value_date = models.DateTimeField(blank=True, null=True)
value_float = models.FloatField(blank=True, null=True)
value_int = models.IntegerField(blank=True, null=True)
value_int = models.BigIntegerField(blank=True, null=True)
value_text = models.TextField(blank=True, null=True)
value_json = JSONField(

View file

@ -39,7 +39,9 @@ ignore =
DAR203
per-file-ignores =
test_project/migrations/*.py: N806, WPS102, WPS114
# Allow to have magic numbers inside migrations and wrong module names:
*/migrations/*.py: WPS102, WPS114, WPS432
# Allow `__init__.py` with logic for configuration:
test_project/settings.py: S105, WPS226, WPS407
tests/test_*.py: N806, S101, S404, S603, S607, WPS118, WPS226, WPS432, WPS442

View file

@ -99,3 +99,13 @@ class Attributes(TestCase):
v1 = Value.objects.filter(entity_uuid=d1.pk).first()
assert isinstance(repr(v1), str)
assert isinstance(str(v1), str)
def test_big_integer(self):
"""Tests an integer larger than 32-bit a value."""
big_num = 3147483647
patient = Patient.objects.create(name='Jon')
patient.eav.age = big_num
patient.save()
assert patient.eav.age == big_num