#27060: Take indexes into account in inspectdb command
-------------------------------------+-------------------------------------
     Reporter:  Akshesh Doshi        |                    Owner:  Drew
                                     |  Winstel
         Type:  New feature          |                   Status:  assigned
    Component:  Core (Management     |                  Version:  dev
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  db-indexes           |             Triage Stage:  Accepted
  inspectdb                          |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by David Wobrock):

 * cc: David Wobrock (added)


Comment:

 I started looking a bit into this ticket, and one of the issues I
 encounter is that we don't get back most parameters needed to reconstruct
 the `Index` class.
 With the current `introspection.get_constraint` implementations, we will
 mainly be able to re-create the fields and order. We have some
 information, but:
 - few information about `expressions` (we could mainly infer that we used
 expressions if no columns are specified for that index)
 - nothing about `opclasses` (even if postgresql specific)
 - nothing about `db_tablespace`
 - nothing about `condition`
 - nothing about `include` (even if postgresql specific)
 And I strongly suspect nothing either on `buffering`, `fillfactor` and
 others for `postgresql.indexes` :/

 The best I can think of would be to
 1. add a new introspection method for each database, that would allow to
 fetch the `CREATE INDEX` SQL statement from a tablename+indexname (if this
 is possible on all supported databases)
 2. from the SQL statement, try to reverse engineer it in a best effort
 manner and extract all given elements. Some elements will be very
 difficult to express in Django again (like expressions), so we probably
 should display a comment with the original `CREATE INDEX`

 How does that sound? (to me a bit brittle admittedly)

 An even simpler approach could be to only handle fields+order, and always
 add the `CREATE INDEX` statement as a comment for the user then to
 manually convert it to the right `Index` parameters.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/27060#comment:13>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070180e6ac11ec-eecce61a-a79d-47ab-a74c-9ed1f59a1936-000000%40eu-central-1.amazonses.com.

Reply via email to