diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-05-07 13:46:23 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-05-07 13:47:02 -0700 |
| commit | d8bf415ab29ef3ef843286e69c646ebcce58c172 (patch) | |
| tree | 4c7b6fba90d7cb58a2000011e4a2a4158831507a /django/db/backends/sqlite3 | |
| parent | f67433e74b06bbeb9b6bba0a9db5fb33512bdb43 (diff) | |
[1.7.x] Fixed #22581: Pass default values for schema through get_db_prep_save()
Diffstat (limited to 'django/db/backends/sqlite3')
| -rw-r--r-- | django/db/backends/sqlite3/schema.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index a8417d4f66..005d4b13c8 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -1,3 +1,4 @@ +from decimal import Decimal from django.utils import six from django.apps.registry import Apps from django.db.backends.schema import BaseDatabaseSchemaEditor @@ -19,6 +20,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): # Manual emulation of SQLite parameter quoting if isinstance(value, type(True)): return str(int(value)) + elif isinstance(value, (Decimal, float)): + return str(value) elif isinstance(value, six.integer_types): return str(value) elif isinstance(value, six.string_types): @@ -26,7 +29,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): elif value is None: return "NULL" else: - raise ValueError("Cannot quote parameter value %r" % value) + raise ValueError("Cannot quote parameter value %r of type %s" % (value, type(value))) def _remake_table(self, model, create_fields=[], delete_fields=[], alter_fields=[], rename_fields=[], override_uniques=None): """ @@ -52,7 +55,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): # If there's a default, insert it into the copy map if field.has_default(): mapping[field.column] = self.quote_value( - field.get_default() + self.effective_default(field) ) # Add in any altered fields for (old_field, new_field) in alter_fields: |
