Opened 18 years ago

Closed 18 years ago

#4012 closed (duplicate)

"ProgrammingError: syntax error" when loading (JSON) serialized data

Reported by: eduardo.padoan@… Owned by: Jacob
Component: Core (Serialization) Version: dev
Severity: Keywords: JSON
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm using rev. 4993. My model is:
(testproj.testapp)

from django.db import models

class TestModel(models.Model):
    name = models.CharField(maxlength=10)

Then:

$ ./manage.py shell
Python 2.5.1c1 (release25-maint, Apr  6 2007, 22:02:36)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from testproj.testapp. models import TestModel
>>> test_obj = TestModel(name="Foo")
>>> test_obj.save()
>>>

...And:

$ ./manage.py dumpdata testapp
[{"pk": "1", "model": "testapp.testmodel", "fields": {"name": "Foo"}}]

OK it is there. Lets get it back:

$ ./manage.py dumpdata testapp > test.json
$ ./manage.py loaddata test.json
Loading 'test' fixtures...
Installing json fixture 'test' from absolute path.
Installed 1 object(s) from 1 fixture(s)
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management.py", line 1669, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.5/site-packages/django/core/management.py", line 1583, in execute_from_command_line
    action_mapping[action](args[1:], int(options.verbosity))
  File "/usr/lib/python2.5/site-packages/django/core/management.py", line 1413, in load_data
    cursor.execute(line)
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py", line 12, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: syntax error at or near "

On "screen -U" (unicode), the error message ends on the ". I have to type Enter to get my shell back.
Without screen:

[...]
psycopg2.ProgrammingError: syntax error at or near "
INE 1: SELECT setval('testapp_testmodel_id_seq'...
        ^

Change History (4)

comment:1 by James Bennett, 18 years ago

At first glance this appears to be a duplicate of #3790; are you using a Django Subversion checkout later than revision 4937 (revision 4937 was *after* the 0.96 release)?

in reply to:  1 comment:2 by anonymous, 18 years ago

Replying to ubernostrum:

At first glance this appears to be a duplicate of #3790; are you using a Django Subversion
checkout later than revision 4937 (revision 4937 was *after* the 0.96 release)?

As I said, I'm using revison 4993.
#3790 is an IntegrityError, no a ProgrammingError. In another test I cleaned the database before trying to load the .json, and the same error happened.

comment:3 by James Bennett, 18 years ago

Hm. I think I was looking at the wrong ticket; #3954 sounds more like what's happening to you (the sequence reset is sending something bad to the DB).

comment:4 by anonymous, 18 years ago

Resolution: duplicate
Status: newclosed

Yes, the patch to remove colors on sql on #3954 resolved the problem. Thanks and sorry for the duplication.

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