diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-05-14 05:48:44 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-05-14 05:48:44 +0000 |
| commit | 13ae9e484d6dbd1ab0affee07922a5337591fa5f (patch) | |
| tree | fa7bc9b9da0a487909762a421e603a601eb7f6d0 /django/db | |
| parent | 4e5681caf38d984c31224ac73fe25ca7f89d8ac6 (diff) | |
newforms-admin: Merged from trunk up to [7526].
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7533 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/oracle/query.py | 8 | ||||
| -rw-r--r-- | django/db/models/base.py | 28 | ||||
| -rw-r--r-- | django/db/models/query.py | 4 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 3 | ||||
| -rw-r--r-- | django/db/models/sql/where.py | 6 |
5 files changed, 13 insertions, 36 deletions
diff --git a/django/db/backends/oracle/query.py b/django/db/backends/oracle/query.py index 033ffe8533..7e50c7b5db 100644 --- a/django/db/backends/oracle/query.py +++ b/django/db/backends/oracle/query.py @@ -1,6 +1,6 @@ """ -Custom Query class for this backend (a derivative of -django.db.models.sql.query.Query). +Custom Query class for Oracle. +Derives from: django.db.models.sql.query.Query """ import datetime @@ -12,8 +12,8 @@ _classes = {} def query_class(QueryClass, Database): """ - Returns a custom djang.db.models.sql.query.Query subclass that is - appropraite for Oracle. + Returns a custom django.db.models.sql.query.Query subclass that is + appropriate for Oracle. The 'Database' module (cx_Oracle) is passed in here so that all the setup required to import it only needs to be done by the calling module. diff --git a/django/db/models/base.py b/django/db/models/base.py index e1f846034c..01c2f31794 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -234,32 +234,6 @@ class Model(object): raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0] dispatcher.send(signal=signals.post_init, sender=self.__class__, instance=self) - def from_sequence(cls, values): - """ - An alternate class constructor, primarily for internal use. - - Creates a model instance from a sequence of values (which corresponds - to all the non-many-to-many fields in creation order. If there are more - fields than values, the remaining (final) fields are given their - default values. - - ForeignKey fields can only be initialised using id values, not - instances, in this method. - """ - dispatcher.send(signal=signals.pre_init, sender=cls, args=values, - kwargs={}) - obj = Empty() - obj.__class__ = cls - field_iter = iter(obj._meta.fields) - for val, field in izip(values, field_iter): - setattr(obj, field.attname, val) - for field in field_iter: - setattr(obj, field.attname, field.get_default()) - dispatcher.send(signal=signals.post_init, sender=cls, instance=obj) - return obj - - from_sequence = classmethod(from_sequence) - def __repr__(self): return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self))) @@ -362,6 +336,8 @@ class Model(object): dispatcher.send(signal=signals.post_save, sender=self.__class__, instance=self, created=(not record_exists), raw=raw) + save_base.alters_data = True + def validate(self): """ First coerces all fields on this instance to their proper Python types. diff --git a/django/db/models/query.py b/django/db/models/query.py index 65048c7ba8..6b341ba9ab 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -164,7 +164,7 @@ class QuerySet(object): obj, _ = get_cached_row(self.model, row, index_start, max_depth, requested=requested) else: - obj = self.model.from_sequence(row[index_start:]) + obj = self.model(*row[index_start:]) for i, k in enumerate(extra_select): setattr(obj, k, row[i]) yield obj @@ -655,7 +655,7 @@ def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0, restricted = requested is not None index_end = index_start + len(klass._meta.fields) - obj = klass.from_sequence(row[index_start:index_end]) + obj = klass(*row[index_start:index_end]) for f in klass._meta.fields: if (not f.rel or (not restricted and f.null) or (restricted and f.name not in requested) or f.rel.parent_link): diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 7e9fb00418..a6957bab7b 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -394,7 +394,8 @@ class Query(object): some cases to avoid ambiguitity with nested queries. """ qn = self.quote_name_unless_alias - result = ['(%s) AS %s' % (col, alias) for alias, col in self.extra_select.iteritems()] + qn2 = self.connection.ops.quote_name + result = ['(%s) AS %s' % (col, qn2(alias)) for alias, col in self.extra_select.iteritems()] aliases = set(self.extra_select.keys()) if with_aliases: col_aliases = aliases.copy() diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index c8857a01fe..3e8bfed087 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -51,12 +51,12 @@ class WhereNode(tree.Node): format = '(%s)' elif isinstance(child, tree.Node): sql, params = self.as_sql(child, qn) - if len(child.children) == 1: + if child.negated: + format = 'NOT (%s)' + elif len(child.children) == 1: format = '%s' else: format = '(%s)' - if child.negated: - format = 'NOT %s' % format else: sql, params = self.make_atom(child, qn) format = '%s' |
