#22873: Allow disabling debug cursor when DEBUG=True
-------------------------------------+-------------------------------------
     Reporter:  john@…               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

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


Comment:

 Indeed, `use_debug_cursor` was a tri-valued boolean. That ranks quite high
 on my scale of programming anti-patterns. Furthermore, one of the three
 values was never used by Django.

 So I changed it to a regular boolean. The new logic is:

 * If db.connection.use_debug_cursor is a true-ish value, use a debug
 cursor;
 * If db.connection.use_debug_cursor is a false-ish value, defer to
 `settings.DEBUG`.

 `None` is just a false-ish value among others.

 I should have changed the name to something like `force_debug_cursor` but
 I didn't find a short and explicit name so I left it as is. Suggestions?

 I don't think the tri-valued boolean behaviour was introduced on purpose
 because it wasn't documented. It was a private API with no guarantee that
 its behaviour will be preserved across versions.

 Accepting to fix this ticket would mean turning `use_debug_cursor` into a
 public API with its previous three-valued behaviour. I'm very close to -1
 on this, but I'll let someone else confirm in case that behaviour was
 there for a good reason. If it was, it must be documented.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22873#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/080.37f997fcd5d9f920cafd94ced81f234f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to