|
@@ -33,28 +33,10 @@ class Index:
|
|
|
for field_name in self.fields
|
|
|
]
|
|
|
self.name = name or ''
|
|
|
- if self.name:
|
|
|
- errors = self.check_name()
|
|
|
- if len(self.name) > self.max_name_length:
|
|
|
- errors.append('Index names cannot be longer than %s characters.' % self.max_name_length)
|
|
|
- if errors:
|
|
|
- raise ValueError(errors)
|
|
|
self.db_tablespace = db_tablespace
|
|
|
self.opclasses = opclasses
|
|
|
self.condition = condition
|
|
|
|
|
|
- def check_name(self):
|
|
|
- errors = []
|
|
|
-
|
|
|
- if self.name[0] == '_':
|
|
|
- errors.append('Index names cannot start with an underscore (_).')
|
|
|
- self.name = 'D%s' % self.name[1:]
|
|
|
-
|
|
|
- elif self.name[0].isdigit():
|
|
|
- errors.append('Index names cannot start with a number (0-9).')
|
|
|
- self.name = 'D%s' % self.name[1:]
|
|
|
- return errors
|
|
|
-
|
|
|
def _get_condition_sql(self, model, schema_editor):
|
|
|
if self.condition is None:
|
|
|
return None
|
|
@@ -122,7 +104,8 @@ class Index:
|
|
|
'Index too long for multiple database support. Is self.suffix '
|
|
|
'longer than 3 characters?'
|
|
|
)
|
|
|
- self.check_name()
|
|
|
+ if self.name[0] == '_' or self.name[0].isdigit():
|
|
|
+ self.name = 'D%s' % self.name[1:]
|
|
|
|
|
|
def __repr__(self):
|
|
|
return "<%s: fields='%s'%s>" % (
|