-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75cbd78
commit cc4eeaf
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.. _tinyintegerfields: | ||
|
||
---------------- | ||
TinyIntegerField | ||
---------------- | ||
|
||
.. currentmodule:: django_mysql.models | ||
|
||
When working with integers that fit within small ranges, the default integer | ||
fields can lead to excessive storage usage. MySQL’s ``TINYINT`` type allows | ||
efficient storage by limiting the size to one byte. | ||
The `TinyIntegerField` and `PositiveTinyIntegerField` make it easy to use | ||
the ``TINYINT`` and ``TINYINT UNSIGNED`` types in Django. | ||
|
||
Docs: | ||
`MySQL TINYINT <https://dev.mysql.com/doc/refman/en/numeric-types.html>`_ / | ||
`MariaDB <https://mariadb.com/kb/en/tinyint/>`_. | ||
|
||
.. class:: TinyIntegerField(**kwargs) | ||
|
||
A subclass of Django’s :class:`~django.db.models.SmallIntegerField` that uses a MySQL | ||
``TINYINT`` type for storage. It supports signed integer values ranging from -128 to 127. | ||
|
||
Example: | ||
|
||
.. code-block:: python | ||
from django.db import models | ||
from myapp.fields import TinyIntegerField | ||
class ExampleModel(models.Model): | ||
tiny_value = TinyIntegerField() | ||
.. class:: PositiveTinyIntegerField(**kwargs) | ||
|
||
A subclass of Django’s :class:`~django.db.models.PositiveSmallIntegerField` that uses a | ||
MySQL ``TINYINT UNSIGNED`` type for storage. It supports unsigned integer values ranging | ||
from 0 to 255. | ||
|
||
Example: | ||
|
||
.. code-block:: python | ||
from django.db import models | ||
from myapp.fields import PositiveTinyIntegerField | ||
class ExampleModel(models.Model): | ||
positive_tiny_value = PositiveTinyIntegerField() | ||
.. note:: | ||
Ensure that existing data values fall within the specified ranges before migrating | ||
to this field, as values outside these ranges will cause migration operations to fail. |