Code

Ticket #19713: 0001-Renamed-inspectdb-field-names-for-clarity.patch

File 0001-Renamed-inspectdb-field-names-for-clarity.patch, 8.5 KB (added by charettes, 17 months ago)
  • tests/regressiontests/inspectdb/models.py

    From 85159c258ff315f5636905cdf6163b183278f3aa Mon Sep 17 00:00:00 2001
    From: Simon Charette <charette.s@gmail.com>
    Date: Thu, 31 Jan 2013 20:00:25 -0500
    Subject: [PATCH] Renamed inspectdb field names for clarity
    
    ---
     tests/regressiontests/inspectdb/models.py |   44 +++++++++----------
     tests/regressiontests/inspectdb/tests.py  |   68 +++++++++++++----------------
     2 files changed, 53 insertions(+), 59 deletions(-)
    
    diff --git a/tests/regressiontests/inspectdb/models.py b/tests/regressiontests/inspectdb/models.py
    index 057ff69..ff9f6f0 100644
    a b class SpecialColumnName(models.Model): 
    3232 
    3333class ColumnTypes(models.Model): 
    3434    id = models.AutoField(primary_key=True) 
    35     field1 = models.BigIntegerField() 
    36     field2 = models.BooleanField() 
    37     field2b = models.NullBooleanField() 
    38     field3 = models.CharField(max_length=10) 
    39     field4 = models.CommaSeparatedIntegerField(max_length=99) 
    40     field5 = models.DateField() 
    41     field6 = models.DateTimeField() 
    42     field7 = models.DecimalField(max_digits=6, decimal_places=1) 
    43     field8 = models.EmailField() 
    44     field9 = models.FileField(upload_to="unused") 
    45     field10 = models.FilePathField() 
    46     field11 = models.FloatField() 
    47     field12 = models.IntegerField() 
    48     field13 = models.IPAddressField() 
    49     field14 = models.GenericIPAddressField(protocol="ipv4") 
    50     field16 = models.PositiveIntegerField() 
    51     field17 = models.PositiveSmallIntegerField() 
    52     field18 = models.SlugField() 
    53     field19 = models.SmallIntegerField() 
    54     field20 = models.TextField() 
    55     field21 = models.TimeField() 
    56     field22 = models.URLField() 
     35    big_int_field = models.BigIntegerField() 
     36    bool_field = models.BooleanField() 
     37    null_bool_field = models.NullBooleanField() 
     38    char_field = models.CharField(max_length=10) 
     39    comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99) 
     40    date_field = models.DateField() 
     41    date_time_field = models.DateTimeField() 
     42    decimal_field = models.DecimalField(max_digits=6, decimal_places=1) 
     43    email_field = models.EmailField() 
     44    file_field = models.FileField(upload_to="unused") 
     45    file_path_field = models.FilePathField() 
     46    float_field = models.FloatField() 
     47    int_field = models.IntegerField() 
     48    ip_address_field = models.IPAddressField() 
     49    gen_ip_adress_field = models.GenericIPAddressField(protocol="ipv4") 
     50    pos_int_field = models.PositiveIntegerField() 
     51    pos_small_int_field = models.PositiveSmallIntegerField() 
     52    slug_field = models.SlugField() 
     53    small_int_field = models.SmallIntegerField() 
     54    text_field = models.TextField() 
     55    time_field = models.TimeField() 
     56    url_field = models.URLField() 
  • tests/regressiontests/inspectdb/tests.py

    diff --git a/tests/regressiontests/inspectdb/tests.py b/tests/regressiontests/inspectdb/tests.py
    index 56c7275..33fd567 100644
    a b class InspectDBTestCase(TestCase): 
    3535            self.assertEqual(definition, out_def) 
    3636 
    3737        assertFieldType('id', "models.IntegerField(primary_key=True)") 
    38         assertFieldType('field1', "models.BigIntegerField()") 
     38        assertFieldType('big_int_field', "models.BigIntegerField()") 
    3939        if connection.vendor == 'mysql': 
    4040            # No native boolean type on MySQL 
    41             assertFieldType('field2', "models.IntegerField()") 
    42             assertFieldType('field2b', "models.IntegerField(null=True, blank=True)") 
     41            assertFieldType('bool_field', "models.IntegerField()") 
     42            assertFieldType('null_bool_field', "models.IntegerField(blank=True, null=True)") 
    4343        else: 
    44             assertFieldType('field2', "models.BooleanField()") 
    45             assertFieldType('field2b', "models.NullBooleanField()") 
    46         assertFieldType('field3', "models.CharField(max_length=10)") 
    47         # CommaSeparatedIntegerField 
    48         assertFieldType('field4', "models.CharField(max_length=99)") 
    49         assertFieldType('field5', "models.DateField()") 
    50         assertFieldType('field6', "models.DateTimeField()") 
     44            assertFieldType('bool_field', "models.BooleanField()") 
     45            assertFieldType('null_bool_field', "models.NullBooleanField()") 
     46        assertFieldType('char_field', "models.CharField(max_length=10)") 
     47        assertFieldType('comma_separated_int_field', "models.CharField(max_length=99)") 
     48        assertFieldType('date_field', "models.DateField()") 
     49        assertFieldType('date_time_field', "models.DateTimeField()") 
    5150        if connection.vendor == 'sqlite': 
    5251            # Ticket #5014 
    53             assertFieldType('field7', "models.DecimalField(max_digits=None, decimal_places=None)") 
     52            assertFieldType('decimal_field', "models.DecimalField(max_digits=None, decimal_places=None)") 
    5453        elif connection.vendor == 'mysql': 
    5554            pass # Ticket #5014 
    5655        else: 
    57             assertFieldType('field7', "models.DecimalField(max_digits=6, decimal_places=1)") 
    58         # EmailField 
    59         assertFieldType('field8', "models.CharField(max_length=75)") 
    60         # FileField 
    61         assertFieldType('field9', "models.CharField(max_length=100)") 
    62         # FilePathField 
    63         assertFieldType('field10', "models.CharField(max_length=100)") 
    64         assertFieldType('field11', "models.FloatField()") 
    65         assertFieldType('field12', "models.IntegerField()") 
     56            assertFieldType('decimal_field', "models.DecimalField(max_digits=6, decimal_places=1)") 
     57        assertFieldType('email_field', "models.CharField(max_length=75)") 
     58        assertFieldType('file_field', "models.CharField(max_length=100)") 
     59        assertFieldType('file_path_field', "models.CharField(max_length=100)") 
     60        assertFieldType('float_field', "models.FloatField()") 
     61        assertFieldType('int_field', "models.IntegerField()") 
    6662        if connection.vendor == 'postgresql': 
    6763            # Only PostgreSQL has a specific type 
    68             assertFieldType('field13', "models.GenericIPAddressField()") 
    69             assertFieldType('field14', "models.GenericIPAddressField()") 
     64            assertFieldType('ip_address_field', "models.GenericIPAddressField()") 
     65            assertFieldType('gen_ip_adress_field', "models.GenericIPAddressField()") 
    7066        else: 
    71             assertFieldType('field13', "models.CharField(max_length=15)") 
    72             assertFieldType('field14', "models.CharField(max_length=39)") 
     67            assertFieldType('ip_address_field', "models.CharField(max_length=15)") 
     68            assertFieldType('gen_ip_adress_field', "models.CharField(max_length=39)") 
    7369        if connection.vendor == 'sqlite': 
    74             assertFieldType('field16', "models.PositiveIntegerField()") 
    75             assertFieldType('field17', "models.PositiveSmallIntegerField()") 
     70            assertFieldType('pos_int_field', "models.PositiveIntegerField()") 
     71            assertFieldType('pos_small_int_field', "models.PositiveSmallIntegerField()") 
    7672        else: 
    7773            # 'unsigned' property undetected on other backends 
    78             assertFieldType('field16', "models.IntegerField()") 
     74            assertFieldType('pos_int_field', "models.IntegerField()") 
    7975            if connection.vendor == 'postgresql': 
    80                 assertFieldType('field17', "models.SmallIntegerField()") 
     76                assertFieldType('pos_small_int_field', "models.SmallIntegerField()") 
    8177            else: 
    82                 assertFieldType('field17', "models.IntegerField()") 
    83         # SlugField 
    84         assertFieldType('field18', "models.CharField(max_length=50)") 
     78                assertFieldType('pos_small_int_field', "models.IntegerField()") 
     79        assertFieldType('slug_field', "models.CharField(max_length=50)") 
    8580        if connection.vendor in ('sqlite', 'postgresql'): 
    86             assertFieldType('field19', "models.SmallIntegerField()") 
     81            assertFieldType('small_int_field', "models.SmallIntegerField()") 
    8782        else: 
    88             assertFieldType('field19', "models.IntegerField()") 
    89         assertFieldType('field20', "models.TextField()") 
    90         assertFieldType('field21', "models.TimeField()") 
    91         # URLField 
    92         assertFieldType('field22', "models.CharField(max_length=200)") 
     83            assertFieldType('small_int_field', "models.IntegerField()") 
     84        assertFieldType('text_field', "models.TextField()") 
     85        assertFieldType('time_field', "models.TimeField()") 
     86        assertFieldType('url_field', "models.CharField(max_length=200)") 
    9387 
    9488    @skipUnlessDBFeature('can_introspect_foreign_keys') 
    9589    def test_attribute_name_not_python_keyword(self):