#25020: Provide/log related args (SQL query, params, proc) with database errors
----------------------------------------------+--------------------
Reporter: blueyed | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Database errors should provide the SQL query being used (the `sql` and
maybe `params` separately), e.g. in case of a `DataError`.
`DatabaseErrorWrapper` might just log these as an error, in case the
reason is for the exception message not getting too long - but it's
probably easier/better to apply this to `CursorWrapper.execute`,
`CursorWrapper.executemany` and `CursorWrapper.callproc` (via some
specialized context manager, which could be passed in relevant args that
should be logged or added to the exception in case of error)?
It is annoying to figure out where e.g. some varchar length restriction
might come from, and the SQL/params would make it more obvious.
While you can log queries with the `django.db logger`,
`CursorDebugWrapper` or directly in Postgres, the former (logging queries
in general) is noisy (and therefore not useful / usually enabled by
default) and logging them in your DB should be abstracted away by Django
and might be even not possible, in case you cannot control the DB settings
in this regard.
--
Ticket URL: <https://code.djangoproject.com/ticket/25020>
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/050.3a2d9d61eda39a99f4de9066706bf2fd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.