Ticket #4492: ticket-4492_r5743.diff

File ticket-4492_r5743.diff, 3.4 KB (added by John Shaffer <jshaffer2112@…>, 17 years ago)

Patch against [5743], with tests.

  • django/db/backends/postgresql/base.py

     
    271271                style.SQL_FIELD(quote_name('id')),
    272272                style.SQL_KEYWORD('IS NOT'),
    273273                style.SQL_KEYWORD('FROM'),
    274                 style.SQL_TABLE(f.m2m_db_table())))
     274                style.SQL_TABLE(quote_name(f.m2m_db_table()))))
    275275    return output
    276276
    277277def typecast_string(s):
  • django/db/backends/postgresql_psycopg2/base.py

     
    221221                style.SQL_FIELD(quote_name('id')),
    222222                style.SQL_KEYWORD('IS NOT'),
    223223                style.SQL_KEYWORD('FROM'),
    224                 style.SQL_TABLE(f.m2m_db_table())))
     224                style.SQL_TABLE(quote_name(f.m2m_db_table()))))
    225225    return output
    226226
    227227OPERATOR_MAPPING = {
  • tests/modeltests/fixtures/fixtures/fixture6.json

     
     1[
     2    {
     3        "pk": "7",
     4        "model": "fixtures.mixedcasem2m",
     5        "fields": {
     6            "relatedItems": [],
     7            "Title": "Poker has no place on ESPN"
     8        }
     9    },
     10    {
     11        "pk": "9",
     12        "model": "fixtures.mixedcasem2m",
     13        "fields": {
     14            "relatedItems": [7],
     15            "Title": "Time to reform copyright"
     16        }
     17    }
     18]
  • tests/modeltests/fixtures/models.py

     
    2020    class Meta:
    2121        ordering = ('-pub_date', 'headline')
    2222
     23class MixedCaseM2M(models.Model):
     24    relatedItems = models.ManyToManyField('self', blank=True, null=True)
     25    Title = models.CharField(maxlength=100, default='Default title')
     26
     27    def __unicode__(self):
     28        return self.Title
     29
     30    class Meta:
     31        ordering = ('Title',)
     32
    2333__test__ = {'API_TESTS': """
    2434>>> from django.core import management
    2535>>> from django.db.models import get_app
     
    7585# Dump the current contents of the database as a JSON fixture
    7686>>> print management.dump_data(['fixtures'], format='json')
    7787[{"pk": "3", "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": "2", "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 12:00:00"}}, {"pk": "1", "model": "fixtures.article", "fields": {"headline": "Python program becomes self aware", "pub_date": "2006-06-16 11:00:00"}}]
     88
     89# Load fixture 6: a JSON file with mixed-case column names.
     90>>> management.load_data(['fixture6.json'], verbosity=0)
     91>>> MixedCaseM2M.objects.all()
     92[<MixedCaseM2M: Poker has no place on ESPN>, <MixedCaseM2M: Time to reform copyright>]
     93>>> mixed = MixedCaseM2M.objects.get(Title__icontains='poker')
     94>>> mixed.relatedItems.all()
     95[<MixedCaseM2M: Time to reform copyright>]
    7896"""}
    7997
    8098from django.test import TestCase
Back to Top