Opened 16 years ago

Closed 16 years ago

#6692 closed (duplicate)

Saving NUL character truncates string using SQLite

Reported by: Alexandre Martani <amartani@…> Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I try to save a string containing NUL character (\x00), only the
part before the character is saved. I have created a simple model:

class Test(models.Model):
  content = models.TextField()

And this happens:

>>> from mysite.test.models import Test
>>> test = Test(content="blabla\x00blablabla")
>>> test.content
'blabla\x00blablabla'
>>> test.save()
>>> test.pk
1
>>> Test.objects.get(pk=1).content
u'blabla'
>>> test.content
'blabla\x00blablabla'

The end of the string is simply lost, no errors are raised, nothing. Since python supports NUL character in strings, Django should support them too, or just drop it, but not losing all the end of the string.
This happens on Django 0.96.1 and SVN, using SQLite database.

Change History (1)

comment:1 by Matt McClanahan, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #2417.

Note: See TracTickets for help on using tickets.
Back to Top