case-sensitive fields/columns in models

Create issue
Issue #1098 new
Tay Ray Chuan created an issue

We still have a few running around.

{{{ $ grep -ERn "[a-z][A-Z][^ =]+ =" --include=models.py . payment/models.py:32: optionName = PaymentChoiceCharField(("Option Name"), max_length=20, payment/models.py:35: sortOrder = models.IntegerField(("Sort Order")) payment/models.py💯 decryptedCC = property(decryptCC) payment/models.py:104: expirationDate = property(_expireDate) product/models.py:454: allowedUses = models.IntegerField(("Number of allowed uses"), product/models.py:456: numUses = models.IntegerField(("Number of times already used"), product/models.py:458: minOrder = CurrencyField(("Minimum order value"), product/models.py:460: startDate = models.DateField(("Start Date")) product/models.py:461: endDate = models.DateField(("End Date")) product/models.py:464: allValid = models.BooleanField(("All products?"), default=False, product/models.py:496: minOrder = self.minOrder or 0 product/models.py:857: taxClass = models.ForeignKey('TaxClass', verbose_name=('Tax Class'), blank=True, null=True, help_text=("If it is taxable what kind of tax?")) product/models.py:1802: numProcessed = 0 product/models.py:1804: optionDict = dict([(sub.option_group.sort_order, sub) for sub in self.options.all()]) product/models.py:1807: if numProcessed == self.options.count(): product/models.py:1846: groupList = [] satchmo_store/shop/models.py:163: numItems = 0 satchmo_store/shop/models.py:192: numItems = property(_numItems) satchmo_store/shop/models.py:279: itemCount = 0 satchmo_store/shop/models.py:283: numItems = property(_get_count) satchmo_store/shop/models.py:330: alreadyInCart = False satchmo_store/shop/models.py:337: looksTheSame = len(details) == similarItem.details.count() satchmo_store/shop/models.py:347: looksTheSame = False satchmo_store/shop/models.py:350: alreadyInCart = True satchmo_store/shop/models.py:907: taxProcessor = get_tax_processor(self) tax/modules/area/models.py:10: taxClass = models.ForeignKey(TaxClass, verbose_name=('Tax Class')) tax/modules/area/models.py:11: taxZone = models.ForeignKey(AdminArea, blank=True, null=True, tax/modules/area/models.py:13: taxCountry = models.ForeignKey(Country, blank=True, null=True, tax/modules/us_sst/models.py:57: taxClass = models.ForeignKey(TaxClass, verbose_name=('Tax Class')) tax/modules/us_sst/models.py:58: taxZone = models.ForeignKey(AdminArea, blank=True, null=True, tax/modules/us_sst/models.py:60: taxCountry = models.ForeignKey(Country, blank=True, null=True, tax/modules/us_sst/models.py:62: isTaxable = models.BooleanField(verbose_name=('Taxable?'), default=True, ) tax/modules/us_sst/models.py:63: useIntrastate = models.BooleanField(verbose_name=('Use Intrastate rate instead of Interstate?'), tax/modules/us_sst/models.py:65: useFood = models.BooleanField(verbose_name=('Use food/drug rate instead of general?'), tax/modules/us_sst/models.py:139: jurisdictionType = models.IntegerField(max_length=2, choices=JURISDICTION_CHOICES, tax/modules/us_sst/models.py:141: jurisdictionFipsCode = models.CharField(max_length=5, tax/modules/us_sst/models.py:143: generalRateIntrastate = models.DecimalField(max_digits=8, decimal_places=7, tax/modules/us_sst/models.py:145: generalRateInterstate = models.DecimalField(max_digits=8, decimal_places=7, tax/modules/us_sst/models.py:147: foodRateIntrastate = models.DecimalField(max_digits=8, decimal_places=7, tax/modules/us_sst/models.py:149: foodRateInterstate = models.DecimalField(max_digits=8, decimal_places=7, tax/modules/us_sst/models.py:151: startDate = models.DateField(verbose_name=('Effective Start Date')) tax/modules/us_sst/models.py:152: endDate = models.DateField(verbose_name=('Effective End Date')) tax/modules/us_sst/models.py:193: recordType = models.CharField(max_length=1, choices=TAX_BOUNDRY_CHOICES, tax/modules/us_sst/models.py:195: startDate = models.DateField(verbose_name=('Effective Start Date')) tax/modules/us_sst/models.py:196: endDate = models.DateField(verbose_name=('Effective End Date')) tax/modules/us_sst/models.py:197: lowAddress = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:199: highAddress = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:201: oddEven = models.CharField(max_length=1, blank=True, null=True, choices=ODD_EVEN_CHOICES, tax/modules/us_sst/models.py:203: streetPreDirection = models.CharField(max_length=2, blank=True, null=True, tax/modules/us_sst/models.py:205: streetName = models.CharField(max_length=20, blank=True, null=True, tax/modules/us_sst/models.py:207: streetSuffix = models.CharField(max_length=4, blank=True, null=True, tax/modules/us_sst/models.py:209: streetPostDirection = models.CharField(max_length=2, blank=True, null=True, tax/modules/us_sst/models.py:211: addressSecondaryAbbr = models.CharField(max_length=4, blank=True, null=True, tax/modules/us_sst/models.py:213: addressSecondaryLow = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:215: addressSecondaryHigh = models.IntegerField(max_length=8, blank=True, null=True, tax/modules/us_sst/models.py:217: addressSecondaryOddEven = models.CharField(max_length=1, blank=True, null=True, tax/modules/us_sst/models.py:219: cityName = models.CharField(max_length=28, blank=True, null=True, tax/modules/us_sst/models.py:221: zipCode = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:225: zipCodeLow = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:227: zipExtensionLow = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:229: zipCodeHigh = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:231: zipExtensionHigh = models.IntegerField(blank=True, null=True, tax/modules/us_sst/models.py:233: serCode = models.CharField(max_length=5, verbose_name=('Composite SER Code'), blank=True, null=True) tax/modules/us_sst/models.py:234: fipsStateCode = models.CharField(max_length=2, blank=True, null=True, tax/modules/us_sst/models.py:236: fipsStateIndicator = models.CharField(max_length=2, blank=True, null=True, tax/modules/us_sst/models.py:238: fipsCountyCode = models.CharField(max_length=3, blank=True, null=True, tax/modules/us_sst/models.py:240: fipsPlaceCode = models.CharField(max_length=5, blank=True, null=True, tax/modules/us_sst/models.py:242: fipsPlaceType = models.CharField(max_length=2, blank=True, null=True, tax/modules/us_sst/models.py:288: useIntrastate = None tax/modules/us_sst/models.py:289: useFood = None tax/modules/us_sst/models.py:342: if self.recordType == 'Z': tax/modules/us_sst/models.py:346: elif self.recordType == '4': tax/modules/us_sst/models.py:396:# taxRate = models.ForeignKey(TaxRate, verbose_name=('Tax Rate')) tax/modules/us_sst/models.py:397:# useIntrastate = models.BooleanField(verbose_name=('Use Intrastate rate instead of Interstate?'), tax/modules/us_sst/models.py:399:# useFood = models.BooleanField(verbose_name=('Use food/drug rate instead of general?'), }}}

Almost 70+ offending fields.

Should we do something about them?

Comments (3)

  1. Chris Moffitt repo owner

    (Reply via ch...@moffitts.net):

    This is a good question. I don't know that the field names are causing issues. It had to do more with table names.

    Unless someone has a really big problem, I don't want to make this big a change. I would suspect if others had noticed this issue we would have heard about it by now.

  2. John-Scott Atlakson

    It does make it a pain when working from dbshell to have to remember to manually quote certain field names in PostgreSQL. Some of the above are just method/attribute/variable names and not actual db fields. Excluding these and the last three lines from the commented out TaxCollected model there are 53 camel-cased model field names.

    The more Pythonic and Django-like Satchmo gets and less idiosyncratic, the easier it is to use. I would +1 this change for 1.0. After 0.9.1-final is released I could help with the South migrations if need be, but I would really like to remove the camel-case where it does not belong.

  3. Hynek Cernoch

    about these CamelCases

    It is easy to remember that these are limited only to fields related to tax, discounts and payment.

    Most of these are internals of modules tax.modules.area and tax.modules.us_sst which are not part of default configuration and even when added to settings.py, are never accessed directly from the Satchmo core, only via processor methods.

    Other tables are: payment_paymentoption, payment_creditcarddetail, product_discount and product_product. The field product.taxClass is to be good remembered, because it is probable it can be used in some user code and a temporary backward compatible alias attribute should be provided, not only rename it.

    about changes and South

    Please, do not change the database until the following is resolved. (planned version numbers are not the essentials) Take into account, what is now written in the documentation:

    "The ideal way to migrate would be to dump all of your existing store data, remove all of your old tables, synch the new models and reload the data." (docs/migration.txt)

    This is a pure alibism. (or ideal is meant theoretical not perfect or excellent) Data reload is as complicated or even more than to change the stucture of database with data via writing sql. This is much more important than some CamelCase.

    South has these big problems now: (imho)

    • South can not be enabled at Satchmo installation because of fixtures problems of South.
    • There is no easy a safe method how to detect migration version used some month ago after Satchmo installation, especially if Satchmo has already been upgraded in middletime or migration code had bugs in the time of installation or delay or the changes was minor like adding an index, newertheless obstructing using of an particular migration in the series.
    • The option "--fake" is not a standard unchallenged credible way of activating South. An activating of actual South 0.7.3 (or an older installed) by user, when upgraging to hypothetical Satchmo 1.0, would be a big user problem.
  4. Log in to comment