Code

Opened 7 years ago

Closed 7 years ago

#4012 closed (duplicate)

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

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

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'...
        ^

Attachments (0)

Change History (4)

comment:1 follow-up: Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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)?

comment:2 in reply to: ↑ 1 Changed 7 years ago by anonymous

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 Changed 7 years ago by ubernostrum

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 Changed 7 years ago by anonymous

  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.