diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-07 05:50:26 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-07 05:50:26 +0000 |
| commit | a8a4743b1d2ab84feb9f8e3a2cd5783bce9d178b (patch) | |
| tree | dd8a11b8fc8dedd7d50cbf5cd047f102ef8e1105 /tests | |
| parent | 76cf4db4947254c65df60bfa0df85f49b6703cb2 (diff) | |
[1.0.X] Fixed #9188 -- Fixed a case where we were generating syntactically invalid SQL in some exclude() queries.
Backport of r9588 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9589 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 0eda8f02da..5a41af8dc6 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -227,6 +227,17 @@ class ReservedName(models.Model): def __unicode__(self): return self.name +# A simpler shared-foreign-key setup that can expose some problems. +class SharedConnection(models.Model): + data = models.CharField(max_length=10) + +class PointerA(models.Model): + connection = models.ForeignKey(SharedConnection) + +class PointerB(models.Model): + connection = models.ForeignKey(SharedConnection) + + __test__ = {'API_TESTS':""" >>> t1 = Tag.objects.create(name='t1') >>> t2 = Tag.objects.create(name='t2', parent=t1) @@ -986,6 +997,14 @@ model. But it should still be possible to add new ordering after that. >>> qs = Author.objects.order_by().order_by('name') >>> 'ORDER BY' in qs.query.as_sql()[0] True + +Bug #9188 -- incorrect SQL was being generated for certain types of +exclude() queries that crossed multi-valued relations. + +>>> PointerA.objects.filter(connection__pointerb__id=1) +[] +>>> PointerA.objects.exclude(connection__pointerb__id=1) +[] """} # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
