summaryrefslogtreecommitdiffstats
path: root/awx/lib/site-packages/south/db/generic.py
diff options
context:
space:
mode:
Diffstat (limited to 'awx/lib/site-packages/south/db/generic.py')
-rw-r--r--awx/lib/site-packages/south/db/generic.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/awx/lib/site-packages/south/db/generic.py b/awx/lib/site-packages/south/db/generic.py
index 1a26d955b5..5c1935444d 100644
--- a/awx/lib/site-packages/south/db/generic.py
+++ b/awx/lib/site-packages/south/db/generic.py
@@ -444,12 +444,11 @@ class DatabaseOperations(object):
def _alter_set_defaults(self, field, name, params, sqls):
"Subcommand of alter_column that sets default values (overrideable)"
- # Next, set any default
- if not field.null and field.has_default():
- default = field.get_db_prep_save(field.get_default(), connection=self._get_connection())
- sqls.append(('ALTER COLUMN %s SET DEFAULT %%s ' % (self.quote_name(name),), [default]))
- else:
- sqls.append(('ALTER COLUMN %s DROP DEFAULT' % (self.quote_name(name),), []))
+ # Historically, we used to set defaults here.
+ # But since South 0.8, we don't ever set defaults on alter-column -- we only
+ # use database-level defaults as scaffolding when adding columns.
+ # However, we still sometimes need to remove defaults in alter-column.
+ sqls.append(('ALTER COLUMN %s DROP DEFAULT' % (self.quote_name(name),), []))
def _update_nulls_to_default(self, params, field):
"Subcommand of alter_column that updates nulls to default value (overrideable)"
@@ -835,8 +834,13 @@ class DatabaseOperations(object):
# If there is just one column in the index, use a default algorithm from Django
if len(column_names) == 1 and not suffix:
+ try:
+ _hash = self._digest([column_names[0]])
+ except TypeError:
+ # Django < 1.5 backward compatibility.
+ _hash = self._digest(column_names[0])
return self.shorten_name(
- '%s_%s' % (table_name, self._digest(column_names[0]))
+ '%s_%s' % (table_name, _hash),
)
# Else generate the name for the index by South