diff --git a/tests/modeltests/prefetch_related/models.py b/tests/modeltests/prefetch_related/models.py
index ba998c0..dee8842 100644
--- a/tests/modeltests/prefetch_related/models.py
+++ b/tests/modeltests/prefetch_related/models.py
@@ -5,8 +5,10 @@ from django.db import models
 ## Basic tests
 
 class Author(models.Model):
-    name = models.CharField(max_length=50)
+    name = models.CharField(max_length=50, unique=True)
     first_book = models.ForeignKey('Book', related_name='first_time_authors')
+    favorite_authors = models.ManyToManyField(
+        'self', through='FavoriteAuthors', symmetrical=False, related_name='favors_me')
 
     def __unicode__(self):
         return self.name
@@ -15,6 +17,30 @@ class Author(models.Model):
         ordering = ['id']
 
 
+class AuthorWithAge(Author):
+    author = models.OneToOneField(Author, parent_link=True)
+    age = models.IntegerField()
+
+
+class FavoriteAuthors(models.Model):
+    author = models.ForeignKey(Author, to_field='name', related_name='i_like')
+    likes_author = models.ForeignKey(Author, to_field='name', related_name='likes_me')
+
+    class Meta:
+         ordering = ['id']
+
+
+class AuthorAddress(models.Model):
+    author = models.ForeignKey(Author, to_field='name', related_name='addresses')
+    address = models.TextField()    
+
+    class Meta:
+        ordering = ['id']
+
+    def __unicode__(self):
+        return self.address
+
+
 class Book(models.Model):
     title = models.CharField(max_length=255)
     authors = models.ManyToManyField(Author, related_name='books')
@@ -25,6 +51,12 @@ class Book(models.Model):
     class Meta:
         ordering = ['id']
 
+class BookWithYear(Book):
+    book = models.OneToOneField(Book, parent_link=True)
+    published_year = models.IntegerField()
+    aged_authors = models.ManyToManyField(
+        AuthorWithAge, related_name='books_with_year')
+
 
 class Reader(models.Model):
     name = models.CharField(max_length=50)
diff --git a/tests/modeltests/prefetch_related/tests.py b/tests/modeltests/prefetch_related/tests.py
index 1ef76ce..86d8175 100644
--- a/tests/modeltests/prefetch_related/tests.py
+++ b/tests/modeltests/prefetch_related/tests.py
@@ -1,8 +1,10 @@
 from django.contrib.contenttypes.models import ContentType
 from django.test import TestCase
+from django.utils import unittest
 
-from models import Author, Book, Reader, Qualification, Teacher, Department, TaggedItem, Bookmark
-
+from models import (Author, Book, Reader, Qualification, Teacher, Department,
+                    TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors,
+                    AuthorWithAge, BookWithYear)
 
 class PrefetchRelatedTests(TestCase):
 
@@ -100,6 +102,32 @@ class PrefetchRelatedTests(TestCase):
                 [[u"Amy", u"Belinda"]],    # Jane - Sense and Sense
             ])
 
+    def test_overriding_prefetch(self):
+        with self.assertNumQueries(3):
+            qs = Author.objects.prefetch_related('books', 'books__read_by')
+            lists = [[[unicode(r) for r in b.read_by.all()]
+                      for b in a.books.all()]
+                     for a in qs]
+            self.assertEqual(lists,
+            [
+                [[u"Amy"], [u"Belinda"]],  # Charlotte - Poems, Jane Eyre
+                [[u"Amy"]],                # Anne - Poems
+                [[u"Amy"], []],            # Emily - Poems, Wuthering Heights
+                [[u"Amy", u"Belinda"]],    # Jane - Sense and Sense
+            ])
+        with self.assertNumQueries(3):
+            qs = Author.objects.prefetch_related('books__read_by', 'books')
+            lists = [[[unicode(r) for r in b.read_by.all()]
+                      for b in a.books.all()]
+                     for a in qs]
+            self.assertEqual(lists,
+            [
+                [[u"Amy"], [u"Belinda"]],  # Charlotte - Poems, Jane Eyre
+                [[u"Amy"]],                # Anne - Poems
+                [[u"Amy"], []],            # Emily - Poems, Wuthering Heights
+                [[u"Amy", u"Belinda"]],    # Jane - Sense and Sense
+            ])
+
     def test_get(self):
         """
         Test that objects retrieved with .get() get the prefetch behaviour
@@ -249,3 +277,108 @@ class GenericRelationTests(TestCase):
             tags = [t.tag for b in Bookmark.objects.prefetch_related('tags')
                     for t in b.tags.all()]
             self.assertEqual(sorted(tags), ["django", "python"])
+
+
+class TooManySQLParamsTest(TestCase):
+    def setUp(self):
+        # SQLite has a limit of 1000 parameters per query
+        NUM_OBJS = 1000
+        objs = [Book(title=str(i)) for i in range(0, NUM_OBJS)]
+        # For the limit reason we need to run bulk_create in
+        # multiple batches.
+        for i in range(0, NUM_OBJS / 100):
+            Book.objects.bulk_create(objs[i*100:(i+1)*100])
+
+    @unittest.expectedFailure
+    def test_prefetch(self):
+        # The below query should not raise any exception - we do not
+        # test anything else here.
+        list(Book.objects.prefetch_related('first_time_authors'))
+ 
+
+class MultiTableInheritanceTest(TestCase):
+    def setUp(self):
+        self.book1 = BookWithYear.objects.create(
+            title="Poems", published_year=2010)
+        self.book2 = BookWithYear.objects.create(
+            title="More poems", published_year=2011)
+        self.author1 = AuthorWithAge.objects.create(
+            name='Jane', first_book=self.book1, age=50)
+        self.author2 = AuthorWithAge.objects.create(
+            name='Tom', first_book=self.book1, age=49)
+        self.author3 = AuthorWithAge.objects.create(
+            name='Robert', first_book=self.book2, age=48)
+        self.authorAddress = AuthorAddress.objects.create(
+            author=self.author1, address='SomeStreet 1')
+        self.book2.aged_authors.add(self.author2, self.author3)
+
+    def test_foreignkey(self):
+        with self.assertNumQueries(2):
+            qs = AuthorWithAge.objects.prefetch_related('addresses')
+            addresses = [[unicode(address) for address in obj.addresses.all()] 
+                         for obj in qs]
+        self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []])
+
+    def test_m2m_to_inheriting_model(self):
+        qs = AuthorWithAge.objects.prefetch_related('books_with_year')
+        with self.assertNumQueries(2):
+            lst = [[unicode(book) for book in author.books_with_year.all()]
+                   for author in qs]
+        qs = AuthorWithAge.objects.all()
+        lst2 = [[unicode(book) for book in author.books_with_year.all()]
+                for author in qs]
+        self.assertEquals(lst, lst2)
+
+        qs = BookWithYear.objects.prefetch_related('aged_authors')
+        with self.assertNumQueries(2):
+            lst = [[unicode(author) for author in book.aged_authors.all()]
+                   for book in qs]
+        qs = BookWithYear.objects.all()
+        lst2 = [[unicode(author) for author in book.aged_authors.all()]
+               for book in qs]
+        self.assertEquals(lst, lst2)
+
+    def test_parent_link_prefetch(self):
+        with self.assertRaises(ValueError) as cm:
+            qs = list(AuthorWithAge.objects.prefetch_related('author'))
+        self.assertTrue('prefetch_related' in cm.exception.message)
+
+class ForeignKeyToFieldTest(TestCase):
+    def setUp(self):
+        self.book = Book.objects.create(title="Poems")
+        self.author1 = Author.objects.create(name='Jane', first_book=self.book)
+        self.author2 = Author.objects.create(name='Tom', first_book=self.book)
+        self.author3 = Author.objects.create(name='Robert', first_book=self.book)
+        self.authorAddress = AuthorAddress.objects.create(
+            author=self.author1, address='SomeStreet 1'
+        )
+        FavoriteAuthors.objects.create(author=self.author1,
+                                       likes_author=self.author2)
+        FavoriteAuthors.objects.create(author=self.author2,
+                                       likes_author=self.author3)
+        FavoriteAuthors.objects.create(author=self.author3,
+                                       likes_author=self.author1)
+    
+    def test_foreignkey(self):
+        with self.assertNumQueries(2):
+            qs = Author.objects.prefetch_related('addresses')
+            addresses = [[unicode(address) for address in obj.addresses.all()]
+                         for obj in qs]
+        self.assertEquals(addresses, [[unicode(self.authorAddress)], [], []])
+ 
+    @unittest.expectedFailure
+    def test_m2m(self):
+        with self.assertNumQueries(3):
+            qs = Author.objects.prefetch_related('favorite_authors', 'favors_me')
+            favorites = [(
+                 [unicode(i_like) for i_like in author.favorite_authors.all()],
+                 [unicode(likes_me) for likes_me in author.favors_me.all()]
+                ) for author in qs]
+        self.assertEquals(
+            favorites,
+            [
+                ([unicode(self.author2)],[unicode(self.author3)]),
+                ([unicode(self.author3)],[unicode(self.author1)]),
+                ([unicode(self.author1)],[unicode(self.author2)])
+            ]
+        )
