#25476: bug in array handling hit in get_constraints() for psycopg2?
-------------------------------------+-------------------------------------
     Reporter:  heasus               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  psycopg2 fetchall    |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by heasus):

 * status:  closed => new
 * resolution:  needsinfo =>


Comment:

 This schema reproduces the problem for me:

 {{{CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  SET search_path = public, pg_catalog;
  SET default_tablespace = '';
  SET default_with_oids = false;
  CREATE TABLE children (
     idx bigint NOT NULL,
     fullname character varying(64) NOT NULL
  );
  CREATE SEQUENCE children_idx_seq
     START WITH 1
     INCREMENT BY 1
     NO MINVALUE
     NO MAXVALUE
     CACHE 1;
  ALTER TABLE ONLY children ALTER COLUMN idx SET DEFAULT
      nextval('children_idx_seq'::regclass);
  ALTER TABLE ONLY children
     ADD CONSTRAINT children_pkey PRIMARY KEY (idx);
  CREATE TABLE things (
     sibling bigint NOT NULL,
     child bigint NOT NULL
  );
  ALTER TABLE ONLY things
     ADD CONSTRAINT things_child_fkey FOREIGN KEY (child) REFERENCES
     children(idx) ON DELETE CASCADE;

  ALTER TABLE ONLY things
     ADD CONSTRAINT things_sibling_fkey FOREIGN KEY (sibling) REFERENCES
     children(idx) ON DELETE CASCADE;

  # This is an auto-generated Django model module.
  # You'll have to do the following manually to clean this up:
  #   * Rearrange models' order
  #   * Make sure each model has one field with primary_key=True
  #   * Remove `managed = False` lines if you wish to allow Django to
 create, modify, and delete the table
  # Feel free to rename the models, but don't rename db_table values or
 field names.
  #
  # Also note: You'll have to insert the output of 'django-admin sqlcustom
 [app_label]'
  # into your database.
  from __future__ import unicode_literals

 from django.db import models


 class Children(models.Model):
     idx = models.BigIntegerField(primary_key=True)
     fullname = models.CharField(max_length=64)

     class Meta:
         managed = False
         db_table = 'children'


 class Things(models.Model):
 Traceback (most recent call last):
   File "./manage.py", line 10, in <module>
     execute_from_command_line(sys.argv)
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/__init__.py", line 338, in
 execute_from_command_line
     utility.execute()
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/__init__.py", line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/base.py", line 393, in run_from_argv
     self.execute(*args, **cmd_options)
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/base.py", line 444, in execute
     output = self.handle(*args, **options)
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/commands/inspectdb.py", line 25, in handle
     for line in self.handle_inspection(options):
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/core/management/commands/inspectdb.py", line 72, in
 handle_inspection
     constraints = connection.introspection.get_constraints(cursor,
 table_name)
   File "/home/www/beerdb_debug/lib/python3.4/site-
 packages/django/db/backends/postgresql_psycopg2 /introspection.py", line
 169, in get_constraints
     "foreign_key": tuple(used_cols[0].split(".", 1)) if kind.lower() ==
 "foreign key" else None,
  IndexError: list index out of range
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25476#comment:8>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.28dada3c91f4c55a85732b2056f7259b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to