web/lib/django/db/backends/postgresql/creation.py
changeset 0 0d40e90630ef
child 29 cc9b7e14412b
equal deleted inserted replaced
-1:000000000000 0:0d40e90630ef
       
     1 from django.conf import settings
       
     2 from django.db.backends.creation import BaseDatabaseCreation
       
     3 
       
     4 class DatabaseCreation(BaseDatabaseCreation):
       
     5     # This dictionary maps Field objects to their associated PostgreSQL column
       
     6     # types, as strings. Column-type strings can contain format strings; they'll
       
     7     # be interpolated against the values of Field.__dict__ before being output.
       
     8     # If a column type is set to None, it won't be included in the output.
       
     9     data_types = {
       
    10         'AutoField':         'serial',
       
    11         'BooleanField':      'boolean',
       
    12         'CharField':         'varchar(%(max_length)s)',
       
    13         'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
       
    14         'DateField':         'date',
       
    15         'DateTimeField':     'timestamp with time zone',
       
    16         'DecimalField':      'numeric(%(max_digits)s, %(decimal_places)s)',
       
    17         'FileField':         'varchar(%(max_length)s)',
       
    18         'FilePathField':     'varchar(%(max_length)s)',
       
    19         'FloatField':        'double precision',
       
    20         'IntegerField':      'integer',
       
    21         'IPAddressField':    'inet',
       
    22         'NullBooleanField':  'boolean',
       
    23         'OneToOneField':     'integer',
       
    24         'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)',
       
    25         'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)',
       
    26         'SlugField':         'varchar(%(max_length)s)',
       
    27         'SmallIntegerField': 'smallint',
       
    28         'TextField':         'text',
       
    29         'TimeField':         'time',
       
    30     }
       
    31 
       
    32     def sql_table_creation_suffix(self):
       
    33         assert settings.TEST_DATABASE_COLLATION is None, "PostgreSQL does not support collation setting at database creation time."
       
    34         if settings.TEST_DATABASE_CHARSET:
       
    35             return "WITH ENCODING '%s'" % settings.TEST_DATABASE_CHARSET
       
    36         return ''