class PositiveIntegerRelDbTypeMixin

from django.db.models.fields import PositiveIntegerRelDbTypeMixin


  

Ancestors (MRO)

  1. builtins.object
  2. django.db.models.fields.PositiveIntegerRelDbTypeMixin
def rel_db_type(self, connection)
django.db.models.fields.PositiveIntegerRelDbTypeMixin
Return the data type that a related field pointing to this field should
use. In most cases, a foreign key pointing to a positive integer
primary key will have an integer column data type but some databases
(e.g. MySQL) have an unsigned integer type. In that case
(related_fields_match_type=True), the primary key should return its
db_type.
    def rel_db_type(self, connection):
        """
        Return the data type that a related field pointing to this field should
        use. In most cases, a foreign key pointing to a positive integer
        primary key will have an integer column data type but some databases
        (e.g. MySQL) have an unsigned integer type. In that case
        (related_fields_match_type=True), the primary key should return its
        db_type.
        """
        if connection.features.related_fields_match_type:
            return self.db_type(connection)
        else:
            return self.integer_field_class().db_type(connection=connection)