Changes between Initial Version and Version 1 of Ticket #24912, comment 6


Ignore:
Timestamp:
Jun 4, 2015, 7:28:48 AM (9 years ago)
Author:
Rigel Di Scala

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24912, comment 6

    initial v1  
    1 Interestingly, clearing the `prefetch_related` behavior does not fix the problem:
     1Clearing the `prefetch_related` behaviour with {{{players.prefetch_related(None)}}} makes the test pass.
    22
    3 {{{
    4 >>> players = Player.objects.filter(id=self.player_id)
    5 >>> # Enable prefetching
    6 >>> players = players.prefetch_related('awards')
    7 >>> # Disable prefetching (before the queryset is evaluated)
    8 >>> players.prefetch_related(None)
    9 >>> player = players.get()
    10 >>> # For sqlite3, this fails with "2 != 0":
    11 >>> self.assertEqual(2, len(player.awards.all()))
    12 
    13 (0.000) QUERY = 'SELECT "model_fields_player"."id", "model_fields_player"."name" FROM "model_fields_player" WHERE "model_fields_player"."id" = %s' - PARAMS = ('9674a6f11c044484b89bac792e53e642',); args=('9674a6f11c044484b89bac792e53e642',)
    14 
    15 (0.000) QUERY = 'SELECT ("model_fields_player_awards"."player_id") AS "_prefetch_related_val_player_id", "model_fields_award"."id", "model_fields_award"."name" FROM "model_fields_award" INNER JOIN "model_fields_player_awards" ON ( "model_fields_award"."id" = "model_fields_player_awards"."award_id" ) WHERE "model_fields_player_awards"."player_id" IN (%s)' - PARAMS = ('9674a6f11c044484b89bac792e53e642',); args=('9674a6f11c044484b89bac792e53e642',)
    16 }}}
Back to Top