#17785: PostgreSQL Introspection: get_relations() broken after drop column
----------------------------------------------+----------------------------
     Reporter:  guettli                       |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:  psycopg2
 Triage Stage:  Unreviewed                    |  introspection
Easy pickings:  0                             |  Has patch:  1
                                              |      UI/UX:  0
----------------------------------------------+----------------------------
 Hi,

 if a column gets dropped postgreSQL does not update the attnum of columns
 which have a higher attnum:

 {{{

 # oid: select oid from pg_class where relname='modwork_buchungskreis';

 modwork_eins_d=> select attrelid, attname, atttypid,  attnum from
 pg_attribute where attrelid = 149923 order by attnum; attrelid |
 attname            | atttypid | attnum
 ----------+------------------------------+----------+--------
    149923 | tableoid                     |       26 |     -7
    149923 | cmax                         |       29 |     -6
    149923 | xmax                         |       28 |     -5
    149923 | cmin                         |       29 |     -4
    149923 | xmin                         |       28 |     -3
    149923 | ctid                         |       27 |     -1
    149923 | id                           |     1043 |      1
    149923 | name                         |     1043 |      2
    149923 | ........pg.dropped.3........ |        0 |      3
    149923 | ........pg.dropped.4........ |        0 |      4
    149923 | default                      |       16 |      5
    149923 | beschreibung                 |     1043 |      6
    149923 | archiv                       |     1043 |      7
    149923 | email_sender_id              |     1043 |      8


 }}}

 BTW, the same bug is in django/db/backends/postgresql/introspection.py

 Patch attached. I think it is overkill to write a unittest for this.
 Please let me know if you want a test.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17785>
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 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.

Reply via email to