#25049: Oracle constraints case sensitivity
-------------------------------------+-------------------------------------
     Reporter:  Pogsquog             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  Oracle constraints   |             Triage Stage:
  migration case                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * needs_docs:   => 0
 * easy:  1 => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Old description:

> When using Oracle, migrations which alter the unique constraints of a
> model do not migrate correctly. This appears to be due to a case
> sensitivity difference in Oracle vs other databases.
>
> Tested on Django 1.8 and 1.7 with Oracle 12c
>
> example: models.py
>
> from django.db import models
>
> class DoorCount(models.Model):
>     Day = models.DateField()
>     MinuteOfTheDay = models.PositiveIntegerField()
>     DoorId = models.PositiveIntegerField(null=False, blank=False)
>     LineId = models.PositiveIntegerField(null=False, blank=False,
> default=0)
>     Count = models.PositiveIntegerField(default=0)
>
>     class Meta:
>         # unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId")
> # migration initial 0001
>         unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId")
> # migration 0002
>
> run makemigration with initial
> run makemigration with 0002
> run migrate
> gets "Found wrong number (0) of constraints for TestApp_doorcount(Day,
> MinuteOfTheDay, DoorId)"
>
> Problem appears to be case sensitivity when looking for field names, so
> it does not find the relevant constraint in the database.
>
> Currently I have a workaround to patch site-packages/django/db/schema.py
> with a .lower() on constraints, but this is very annoying for deploying,
> and is probably better fixed in the oracle specific code.

New description:

 When using Oracle, migrations which alter the unique constraints of a
 model do not migrate correctly. This appears to be due to a case
 sensitivity difference in Oracle vs other databases.

 Tested on Django 1.8 and 1.7 with Oracle 12c

 example: models.py
 {{{
 from django.db import models

 class DoorCount(models.Model):
     Day = models.DateField()
     MinuteOfTheDay = models.PositiveIntegerField()
     DoorId = models.PositiveIntegerField(null=False, blank=False)
     LineId = models.PositiveIntegerField(null=False, blank=False,
 default=0)
     Count = models.PositiveIntegerField(default=0)

     class Meta:
         # unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId")
 # migration initial 0001
         unique_together = ("Day", "MinuteOfTheDay", "DoorId", "LineId")  #
 migration 0002
 }}}
 run makemigration with initial
 run makemigration with 0002
 run migrate
 gets "Found wrong number (0) of constraints for TestApp_doorcount(Day,
 MinuteOfTheDay, DoorId)"

 Problem appears to be case sensitivity when looking for field names, so it
 does not find the relevant constraint in the database.

 Currently I have a workaround to patch site-packages/django/db/schema.py
 with a .lower() on constraints, but this is very annoying for deploying,
 and is probably better fixed in the oracle specific code.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25049#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.da05b4e82e8693683d2addfa04590ba5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to