Ticket #7327: 0001-Added-test-and-documentation-for-sub-selects.patch

File 0001-Added-test-and-documentation-for-sub-selects.patch, 1.5 KB (added by sebastian_noack, 7 years ago)
  • docs/db-api.txt

    From 43b35a0a633249a068281c849aae54e8ed3f5c3a Mon Sep 17 00:00:00 2001
    From: Sebastian Noack <sebastian.noack@gmail.com>
    Date: Thu, 29 May 2008 14:15:57 +0200
    Subject: [PATCH] Added test and documentation for sub-selects.
    
    ---
     docs/db-api.txt                         |   12 ++++++++++++
     tests/regressiontests/queries/models.py |    4 ++++
     2 files changed, 16 insertions(+), 0 deletions(-)
    
    diff --git a/docs/db-api.txt b/docs/db-api.txt
    index 405ed87..07095fa 100644
    a b SQL equivalent:: 
    13681368
    13691369    SELECT ... WHERE id IN (1, 3, 4);
    13701370
     1371.. note::
     1372    It is possible to realize sub-selects by using ``in`` lookup.
     1373
     1374    Example::
     1375
     1376        Entry.objects.filter(
     1377            blog__in=Blog.objects.filter(name='Cheddar Talk').values('pk').query)
     1378
     1379    SQL equivalent::
     1380
     1381        SELECT ... WHERE id IN (SELECT id FROM ... WHERE name = 'Cheddar Talk');
     1382
    13711383startswith
    13721384~~~~~~~~~~
    13731385
  • tests/regressiontests/queries/models.py

    diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
    index 5beaf5f..caee08f 100644
    a b in MySQL. This exercises that case. 
    701701>>> mm = ManagedModel.objects.create(data='mm1', tag=t1, is_public=True)
    702702>>> ManagedModel.objects.update(data='mm')
    703703
     704Sub-select using in lookup with Query object.
     705>>> Author.objects.filter(extra__in=ExtraInfo.objects.filter(note__misc='foo').values('pk').query)
     706[<Author: a1>, <Author: a2>]
     707
    704708"""}
    705709
Back to Top