diff options
| author | Tim Graham <timograham@gmail.com> | 2014-12-29 15:14:40 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-31 08:29:17 -0500 |
| commit | 93d73dac91104fd82d44b0dd4521cfa4f31e02aa (patch) | |
| tree | 10dac1f7300e934118c425072463b07b23afda03 /django/db/backends/postgresql_psycopg2/base.py | |
| parent | 32ca159c96339b4856837d7abec376a575ec44ab (diff) | |
Moved DatabaseCreation.data_types properties to DatabaseWrapper.
refs #22340.
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index c1dfa54c95..8b45b5d73e 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -71,6 +71,41 @@ class DatabaseFeatures(BaseDatabaseFeatures): class DatabaseWrapper(BaseDatabaseWrapper): vendor = 'postgresql' + # This dictionary maps Field objects to their associated PostgreSQL column + # types, as strings. Column-type strings can contain format strings; they'll + # be interpolated against the values of Field.__dict__ before being output. + # If a column type is set to None, it won't be included in the output. + data_types = { + 'AutoField': 'serial', + 'BinaryField': 'bytea', + 'BooleanField': 'boolean', + 'CharField': 'varchar(%(max_length)s)', + 'CommaSeparatedIntegerField': 'varchar(%(max_length)s)', + 'DateField': 'date', + 'DateTimeField': 'timestamp with time zone', + 'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)', + 'DurationField': 'interval', + 'FileField': 'varchar(%(max_length)s)', + 'FilePathField': 'varchar(%(max_length)s)', + 'FloatField': 'double precision', + 'IntegerField': 'integer', + 'BigIntegerField': 'bigint', + 'IPAddressField': 'inet', + 'GenericIPAddressField': 'inet', + 'NullBooleanField': 'boolean', + 'OneToOneField': 'integer', + 'PositiveIntegerField': 'integer', + 'PositiveSmallIntegerField': 'smallint', + 'SlugField': 'varchar(%(max_length)s)', + 'SmallIntegerField': 'smallint', + 'TextField': 'text', + 'TimeField': 'time', + 'UUIDField': 'uuid', + } + data_type_check_constraints = { + 'PositiveIntegerField': '"%(column)s" >= 0', + 'PositiveSmallIntegerField': '"%(column)s" >= 0', + } operators = { 'exact': '= %s', 'iexact': '= UPPER(%s)', |
