#34553: Can't create CheckConstraint with percent characters in values on
postgresql due to broken quoting
-------------------------------------+-------------------------------------
     Reporter:  Thomas Kolar         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.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 Thomas Kolar):

 I have discovered a very hacky workaround that should cover quite a few
 use cases, in case anyone else is affected by this and needs a fix ASAP.
 The workaround is to combine a `__contains` check with a `__length` check
 - a string that contains another string and has the same length must be
 equal.

 `__contains` with a `%` IS supported - as it happens, the fact that
 support for this was added is what presumably caused this issue (see
 above).

 In order to do this, the `__length` lookup must be registered as described
 in this stackoverflow answer https://stackoverflow.com/a/68274322 . This
 must obviously happen before migrations are run.

 For obvious reasons, I do not endorse this abstruse tomfoolery as an
 intended solution.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34553#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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188011cb90c-fe82b368-4649-489d-9e6c-31bc5bf48fb4-000000%40eu-central-1.amazonses.com.

Reply via email to