#28201: Saving a Char/TextField with psycopg2 2.7+ raises ValueError: A string
literal cannot contain NUL (0x00) characters is unhandled
-------------------------------------+-------------------------------------
Reporter: CM Lubinski | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
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 Tim Graham):
* component: contrib.admin => Database layer (models, ORM)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
This exception was [https://github.com/psycopg/psycopg2/issues/420
introduced in psycopg2 2.7+]. With psycopg2 < 2.7, there is no exception
and null bytes are silently truncated by PostgreSQL. Other databases that
I tested (SQLite, MySQL, Oracle) allow saving null bytes. This creates
possible cross-database compatibility problems when moving data from those
databases to PostgreSQL, e.g.#28117. I've tentatively closed that ticket
as a duplicate but will reopen it if the solution for this ticket doesn't
address it.
I propose having `CharField` and `TextField` strip null bytes from the
value either a) only on PostgreSQL or b) on all databases. I raised
[https://groups.google.com/d/topic/django-
developers/D1gvXYCezEc/discussion a django-developers thread] to ask for
feedback.
--
Ticket URL: <https://code.djangoproject.com/ticket/28201#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/067.d568433b13e86ec4f920d6bf932ced56%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.