-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Use get_db_prep_value when getting instance attribute value in get_pr… #4782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import uuid | ||
| from django.contrib.contenttypes.fields import ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're missing a newline between stdlib and django imports. |
||
| GenericForeignKey, GenericRelation, | ||
| ) | ||
|
|
@@ -257,3 +258,11 @@ def __str__(self): | |
|
|
||
| class Meta: | ||
| ordering = ['id'] | ||
|
|
||
|
|
||
| # Model for many-to-many with UUID pk test: | ||
|
|
||
| class Pet(models.Model): | ||
| id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
| name = models.CharField(max_length=20) | ||
| people = models.ManyToManyField(Person, related_name='pets') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| from .models import ( | ||
| Author, Author2, AuthorAddress, AuthorWithAge, Bio, Book, Bookmark, | ||
| BookReview, BookWithYear, Comment, Department, Employee, FavoriteAuthors, | ||
| House, LessonEntry, Person, Qualification, Reader, Room, TaggedItem, | ||
| House, LessonEntry, Person, Pet, Qualification, Reader, Room, TaggedItem, | ||
| Teacher, WordEntry, | ||
| ) | ||
|
|
||
|
|
@@ -1161,3 +1161,20 @@ def test_bug(self): | |
| prefetcher = get_prefetcher(self.rooms[0], 'house')[0] | ||
| queryset = prefetcher.get_prefetch_queryset(list(Room.objects.all()))[0] | ||
| self.assertNotIn(' JOIN ', force_text(queryset.query)) | ||
|
|
||
|
|
||
| class UUIDPrefetchRelated(TestCase): | ||
| def setUp(self): | ||
| self.pet = Pet.objects.create(name='Fifi') | ||
| self.pet.people.add( | ||
| *[ | ||
| Person.objects.create(name='Ellen'), | ||
| Person.objects.create(name='George'), | ||
| ] | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't have a to build a list here. The following should do. self.pet.people.add(
Person.objects.create(name='Ellen'),
Person.objects.create(name='George'),
) |
||
|
|
||
| def test_prefetch_related(self): | ||
| with self.assertNumQueries(2): | ||
| pet = Pet.objects.filter(pk=self.pet.pk).prefetch_related('people').first() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can simply this to: pet = Pet.objects.prefetch_related('people').get(pk=self.pet.pk) |
||
| with self.assertNumQueries(0): | ||
| self.assertEqual(2, len(pet.people.all())) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These release notes should be in
1.9.txt, whether the fix is backported or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't usually document bug fixes in major release notes, is there something else you were thinking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently I may be wrong here, not sure. I'm sure @timgraham the docs master will know.