Code

Opened 7 years ago

Closed 7 years ago

#4231 closed (fixed)

manage.py loaddata problem if app name is Capitalised

Reported by: Mark Jarecki <mjarecki@…> Owned by: russellm
Component: Core (Serialization) Version: master
Severity: Keywords: loaddata
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

System: Apache2.2.4, mod_python3.3.1, Python-2.5.1, postgresql-8.2.4, psycopg2-2.0.5.1, latest django version.

Models:

class VenueType(models.Model):
     venueTypeName = models.CharField(maxlength=200, db_index=True)
     venueTypeSlug = models.SlugField(prepopulate_from= 
('venueTypeName',), db_index=True)
     class Admin:
         pass

class Venue(models.Model):
     venueSlug = models.SlugField(prepopulate_from=('venueName',),  
unique=True, db_index=True)
     venueType = models.ManyToManyField(VenueType,  
filter_interface=models.HORIZONTAL)

Process:

   ./manage.py dumpdata --format=json Guide > guide.json

   [Clear database]

   ./manage.py syncdb
	
   ./manage.py loaddata guide.json

Error:

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 "/opt/python/lib/python2.5/site-packages/django/core/ 
management.py", line 1674, in execute_manager
     execute_from_command_line(action_mapping, argv)
   File "/opt/python/lib/python2.5/site-packages/django/core/ 
management.py", line 1588, in execute_from_command_line
     action_mapping[action](args[1:], int(options.verbosity))
   File "/opt/python/lib/python2.5/site-packages/django/core/ 
management.py", line 1418, in load_data
     cursor.execute(line)
   File "/opt/python/lib/python2.5/site-packages/django/db/backends/ 
util.py", line 12, in execute
     return self.cursor.execute(sql, params)
   File "/opt/python/lib/python2.5/site-packages/django/db/backends/ 
postgresql/base.py", line 44, in execute
     return self.cursor.execute(sql, [smart_basestring(p,  
self.charset) for p in params])
psycopg.ProgrammingError: ERROR:  relation "guide_venuetype_id_seq"  
does not exist

SELECT setval('Guide_venuetype_id_seq', (SELECT max("id") FROM  
"Guide_venuetype"));

Test file:

[{"pk": "1", "model": "Guide.venuetype", "fields": {"venueTypeSlug": "stadium", "venueTypeName": "Stadium"}}]

./manage.py sqlall Guide output:

BEGIN;

CREATE TABLE "Guide_venuetype" (

"id" serial NOT NULL PRIMARY KEY,

"venueTypeName" varchar(200) NOT NULL,

"venueTypeSlug" varchar(50) NOT NULL

);

CREATE TABLE "Guide_venue" (

"id" serial NOT NULL PRIMARY KEY,

"venueName" varchar(200) NOT NULL,

"venueSlug" varchar(50) NOT NULL UNIQUE

);

CREATE TABLE "Guide_venue_venueType" (

"id" serial NOT NULL PRIMARY KEY,

"venue_id" integer NOT NULL REFERENCES "Guide_venue" ("id") DEFERRABLE INITIALLY DEFERRED,

"venuetype_id" integer NOT NULL REFERENCES "Guide_venuetype" ("id") DEFERRABLE INITIALLY DEFERRED,

UNIQUE ("venue_id", "venuetype_id")

);

CREATE INDEX "Guide_venuetype_venueTypeName" ON "Guide_venuetype" ("venueTypeName");

CREATE INDEX "Guide_venuetype_venueTypeSlug" ON "Guide_venuetype" ("venueTypeSlug");

CREATE INDEX "Guide_venue_venueName" ON "Guide_venue" ("venueName");

CREATE UNIQUE INDEX "Guide_venue_venueSlug" ON "Guide_venue" ("venueSlug");

COMMIT;

Link to Google Groups Django Users Discoussion:
Loaddata-issue

I hope this is enough information.

Attachments (0)

Change History (2)

comment:1 Changed 7 years ago by russellm

  • Component changed from Uncategorized to Serialization
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from jacob to russellm
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Problem confirmed to exist in [5152]. Problem only occurs if app has a capitalized name; changing the name to lower case (i.e. guide, not Guide) works fine.

Issue seems to be in deriving the naming of the PostgreSQL sequence for the primary key of the table being loaded.

comment:2 Changed 7 years ago by russellm

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

(In [5204]) Fixed #4231 -- Added quoting for sequence names on sequence reset for PostgreSQL. This was causing difficulties if table or application names were capitalized. Thanks for the report, Mark Jarecki.

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.