Changeset 7763
- Timestamp:
- 06/26/08 02:51:19 (5 months ago)
- Files:
-
- django/trunk/django/db/models/query.py (modified) (1 diff)
- django/trunk/django/db/models/sql/subqueries.py (modified) (1 diff)
- django/trunk/tests/regressiontests/model_inheritance_regress/models.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/query.py
r7742 r7763 689 689 self.query = self.query.clone(klass=sql.DateQuery, setup=True) 690 690 self.query.select = [] 691 self.query.add_date_select(self._field .column, self._kind, self._order)691 self.query.add_date_select(self._field, self._kind, self._order) 692 692 if self._field.null: 693 693 self.query.add_filter(('%s__isnull' % self._field.name, False)) django/trunk/django/db/models/sql/subqueries.py
r7635 r7763 358 358 yield date 359 359 360 def add_date_select(self, column, lookup_type, order='ASC'):360 def add_date_select(self, field, lookup_type, order='ASC'): 361 361 """ 362 362 Converts the query into a date extraction query. 363 363 """ 364 alias = self.join((None, self.model._meta.db_table, None, None)) 365 select = Date((alias, column), lookup_type, 364 result = self.setup_joins([field.name], self.get_meta(), 365 self.get_initial_alias(), False) 366 alias = result[3][-1] 367 select = Date((alias, field.column), lookup_type, 366 368 self.connection.ops.date_trunc_sql) 367 369 self.select = [select] django/trunk/tests/regressiontests/model_inheritance_regress/models.py
r7600 r7763 2 2 Regression tests for Model inheritance behaviour. 3 3 """ 4 5 import datetime 4 6 5 7 from django.db import models … … 11 13 class Meta: 12 14 ordering = ('name',) 13 15 14 16 def __unicode__(self): 15 17 return u"%s the place" % self.name … … 36 38 return u"%s the parking lot" % self.name 37 39 40 class Parent(models.Model): 41 created = models.DateTimeField(default=datetime.datetime.now) 42 43 class Child(Parent): 44 name = models.CharField(max_length=10) 45 38 46 __test__ = {'API_TESTS':""" 39 47 # Regression for #7350, #7202 40 # Check that when you create a Parent object with a specific reference to an existent41 # child instance, saving the Parent doesn't duplicate the child.42 # This behaviour is only activated during a raw save - it is mostly relevant to48 # Check that when you create a Parent object with a specific reference to an 49 # existent child instance, saving the Parent doesn't duplicate the child. This 50 # behaviour is only activated during a raw save - it is mostly relevant to 43 51 # deserialization, but any sort of CORBA style 'narrow()' API would require a 44 52 # similar approach. … … 118 126 [[('name', u"Guido's All New House of Pasta"), ('serves_gnocchi', False), ('serves_hot_dogs', False)]] 119 127 128 # Regressions tests for #7105: dates() queries should be able to use fields 129 # from the parent model as easily as the child. 130 >>> obj = Child.objects.create(name='child', created=datetime.datetime(2008, 6, 26, 17, 0, 0)) 131 >>> Child.objects.dates('created', 'month') 132 [datetime.datetime(2008, 6, 1, 0, 0)] 133 120 134 """}
