#4972: manage.py inspectdb fails with TypeError
------------------------------+---------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: new | Component: Tools
Version: 0.96 | Keywords: inspectdb TypeError get_relation
foreign key
Stage: Unreviewed | Has_patch: 0
------------------------------+---------------------------------------------
System:
Windows XP Pro,
PostgreSQL 8.1,
Django 0.96,
Python 2.4.1,
psycopg 2.0.6
Running managepy inspectdb against a postgresql database containing a
table witht foreign key created with:
CREATE TABLE fbk_order ([[BR]]
flock_book_vol VARCHAR(2) NOT NULL,[[BR]]
member_no VARCHAR(6) NOT NULL REFERENCES member (member_no),[[BR]]
copies INT NOT NULL,[[BR]]
date_ordered DATE NOT NULL,[[BR]]
CONSTRAINT fbk_order_key PRIMARY KEY (flock_book_vol, member_no))[[BR]]
WITHOUT OIDS;[[BR]]
fails with a !TypeError at line 38 of introspection.py in
get_relation():[[BR]]
37 # row![0] and row![1] are like "{2}", so strip the curly
braces.[[BR]]
38 relations[int(row![0][1:-1]) - 1] = (int(row![1][1:-1]) - 1,
row![2])[[BR]]
!TypeError: int() argument must be a string or a number
The row returned by postgresql is not in the format indicated by the
comment. row[0] and row[1] are
actually arrays of smallints, not strings - potentially more than one
field could be involved in the relationship. For a single relationship
line 38 should be replaced with:[[BR]]
relations[int(row![0]![0]) - 1] = (int(row![1]![0]) - 1, row![2])
If Django can handle multiple foreign key fields from one table then code
should be added to handle an array size > 1.
--
Ticket URL: <http://code.djangoproject.com/ticket/4972>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---