18
17
'FilePathField': 'varchar(%(max_length)s)',
19
18
'FloatField': 'double precision',
20
19
'IntegerField': 'integer',
20
'BigIntegerField': 'bigint',
21
21
'IPAddressField': 'inet',
22
22
'NullBooleanField': 'boolean',
23
23
'OneToOneField': 'integer',
32
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
33
assert self.connection.settings_dict['TEST_COLLATION'] is None, "PostgreSQL does not support collation setting at database creation time."
34
if self.connection.settings_dict['TEST_CHARSET']:
35
return "WITH ENCODING '%s'" % self.connection.settings_dict['TEST_CHARSET']
38
def sql_indexes_for_field(self, model, f, style):
39
if f.db_index and not f.unique:
40
qn = self.connection.ops.quote_name
41
db_table = model._meta.db_table
42
tablespace = f.db_tablespace or model._meta.db_tablespace
44
sql = self.connection.ops.tablespace_sql(tablespace)
46
tablespace_sql = ' ' + sql
52
def get_index_sql(index_name, opclass=''):
53
return (style.SQL_KEYWORD('CREATE INDEX') + ' ' +
54
style.SQL_TABLE(qn(index_name)) + ' ' +
55
style.SQL_KEYWORD('ON') + ' ' +
56
style.SQL_TABLE(qn(db_table)) + ' ' +
57
"(%s%s)" % (style.SQL_FIELD(qn(f.column)), opclass) +
58
"%s;" % tablespace_sql)
60
output = [get_index_sql('%s_%s' % (db_table, f.column))]
62
# Fields with database column types of `varchar` and `text` need
63
# a second index that specifies their operator class, which is
64
# needed when performing correct LIKE queries outside the
65
# C locale. See #12234.
67
if db_type.startswith('varchar'):
68
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),
69
' varchar_pattern_ops'))
70
elif db_type.startswith('text'):
71
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),