[Django] #30350: CheckConstraint repeatedly deleted and re-added

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30350: CheckConstraint repeatedly deleted and re-added

Django
#30350: CheckConstraint repeatedly deleted and re-added
-------------------------------------+-------------------------------------
               Reporter:  Sigurd     |          Owner:  nobody
  Ljødal                             |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 A `CheckConstraint` with a `Q(x__in=range(y, z))` condition is repeatedly
 deleted and re-added when running `makemigrations`.


 {{{#!python
 models.CheckConstraint(
     check=models.Q(month__in=range(1, 13)),
     name='check_valid_month',
 )
 }}}

 The generated migration looks like this, so I suspect that the issue is
 because the range is converted into a tuple:

 {{{#!python
     operations = [
         migrations.RemoveConstraint(
             model_name='monthlybudget',
             name='check_valid_month',
         ),
         migrations.AddConstraint(
             model_name='monthlybudget',
             constraint=models.CheckConstraint(check=models.Q(month__in=(1,
 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), name='check_valid_month'),
         ),
     ]
 }}}

 A sample project with this issue can be found here:
 https://github.com/ljodal/djangocon-eu-2019

 I'm open to fixing this issue myself, but I would like to clarify what
 would be a correct fix to this issue. I see at least two possible
 solutions, maybe three:
  1. Keep the `range` method call in the generated migration file
  2. Disallow using ranges in check constraints
  3. (At least on PostgreSQL, we could use a range expression in the
 database too.)

--
Ticket URL: <https://code.djangoproject.com/ticket/30350>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.869621f7e9db131f2118867e64583915%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: CheckConstraint repeatedly deleted and re-added

Django
#30350: CheckConstraint repeatedly deleted and re-added
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by felixxm):

 In check constraints you can use `range` lookup and it works fine, e.g.

 {{{#!python
 models.CheckConstraint(
     check=models.Q(month__range=[1, 13]),
     name='check_valid_month',
 )
 }}}

 also casting an iterator to a list works good, e.g.

 {{{#!python
 models.CheckConstraint(
     check=models.Q(month__in=list(range(1, 13))),
     name='check_valid_month',
 )
 }}}

 so in this case iterator is an issue. I would check later if this can be
 easily fix and if not we should document this limitation.

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.82858f5f431f26f2870a8d1dec5d322f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator. (was: CheckConstraint repeatedly deleted and re-added)

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
---------------------------------+------------------------------------
     Reporter:  Sigurd Ljødal    |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Migrations       |                  Version:  2.2
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by felixxm):

 * cc: Ian Foote (added)
 * component:  Database layer (models, ORM) => Migrations
 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.2a915d95f721281ce9c08810a678ed09%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
---------------------------------+------------------------------------
     Reporter:  Sigurd Ljødal    |                    Owner:  felixxm
         Type:  Bug              |                   Status:  assigned
    Component:  Migrations       |                  Version:  2.2
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by felixxm):

 * owner:  nobody => felixxm
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.8bbebf2b12445327f9f8378fbb1a92f8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
---------------------------------+------------------------------------
     Reporter:  Sigurd Ljødal    |                    Owner:  felixxm
         Type:  Bug              |                   Status:  assigned
    Component:  Migrations       |                  Version:  2.2
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by Sigurd Ljødal):

 Just to confirm, I modified the migration to use `range()` and
 `makemigrations` no longer detects any changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:4>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.df8f56a77a634b1e4aaa83d0dbdf5f14%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  assigned
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * owner:  felixxm => Florian Apolloner
 * stage:  Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:5>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.f0f8cf89139f5b28232de3cb05a92d46%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"2e38f2015aba224b68a91a3012b87223f3046bb6" 2e38f20]:
 {{{
 #!CommitTicketReference repository=""
 revision="2e38f2015aba224b68a91a3012b87223f3046bb6"
 Fixed #30350 -- Prevented recreation of migration for operations with a
 range object.

 Thanks to Mariusz Felisiak for helping with the patch.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:6>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.bd894be4514d3f83ca4dd1799f85ad0a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains iterator.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains iterator.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"896cc7190115c5bcdef756fe10dc203d9b03678c" 896cc719]:
 {{{
 #!CommitTicketReference repository=""
 revision="896cc7190115c5bcdef756fe10dc203d9b03678c"
 [2.2.x] Fixed #30350 -- Prevented recreation of migration for operations
 with a range object.

 Thanks to Mariusz Felisiak for helping with the patch.

 Backport of 2e38f2015aba224b68a91a3012b87223f3046bb6 from master.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:7>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.105190a4238354b3bbc3e14a39c2273e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains a range object. (was: Migration re-add check constraint continuously when check condition contains iterator.)

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains a range object.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:8>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.8289d508e304b6709289261dddc6f285%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains a range object.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains a range object.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"bc46e386c7aa496642d3ffc9e4f56ae5a46417a7" bc46e386]:
 {{{
 #!CommitTicketReference repository=""
 revision="bc46e386c7aa496642d3ffc9e4f56ae5a46417a7"
 Refs #30350 -- Doc'd support for range serialization in migrations.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:9>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.f2769eac1c85bfea05817524f44d847b%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains a range object.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains a range object.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"0098f26fdd0a56d6613585de9eec2f34499c3287" 0098f26f]:
 {{{
 #!CommitTicketReference repository=""
 revision="0098f26fdd0a56d6613585de9eec2f34499c3287"
 [3.0.x] Refs #30350 -- Doc'd support for range serialization in
 migrations.

 Backport of bc46e386c7aa496642d3ffc9e4f56ae5a46417a7 from master
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:10>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.c8e29177234d1b0ac223dbf4f9b5c0e6%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30350: Migration re-add check constraint continuously when check condition contains a range object.

Django
In reply to this post by Django
#30350: Migration re-add check constraint continuously when check condition
contains a range object.
-------------------------------------+-------------------------------------
     Reporter:  Sigurd Ljødal        |                    Owner:  Florian
                                     |  Apolloner
         Type:  Bug                  |                   Status:  closed
    Component:  Migrations           |                  Version:  2.2
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"acc0d99e6c1388199ca2275b179051e5a89cdc25" acc0d99e]:
 {{{
 #!CommitTicketReference repository=""
 revision="acc0d99e6c1388199ca2275b179051e5a89cdc25"
 [2.2.x] Refs #30350 -- Doc'd support for range serialization in
 migrations.

 Backport of bc46e386c7aa496642d3ffc9e4f56ae5a46417a7 from master
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30350#comment:11>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.9c0f312e1b8289e3e8e7759be469ecd6%40djangoproject.com.