[Django] #30846: PostGIS not respecting index names

20 views
Skip to first unread message

Django

unread,
Oct 7, 2019, 5:03:36 AM10/7/19
to django-...@googlegroups.com
#30846: PostGIS not respecting index names
--------------------------------------------------+------------------------
Reporter: Thomas Steen Rasmussen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------------+------------------------
Hello,

I am trying to create an index for a table with some geodjango fields. The
PostGIS code doesn't take the index name into account, it always generates
one based on table and field name.
Compare
https://github.com/django/django/blob/master/django/contrib/gis/db/backends/postgis/schema.py#L38
with
https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L967
and it is clear that some logic to determine the name is missing. That
leads to the following result in sqlmigrate:

{{{
--
-- Create index dar_navngivenvej_historik_vvnl on field(s)
vejnavnebeliggenhed_vejnavnelinje of model darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejnavnelinje_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejnavnelinje");
--
-- Create index dar_navngivenvej_historik_vvno on field(s)
vejnavnebeliggenhed_vejnavneområde of model darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejnavneområde_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejnavneområde");
--
-- Create index dar_navngivenvej_historik_vvtp on field(s)
vejnavnebeliggenhed_vejtilslutningspunkter of model
darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejtilslutningspunkter_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejtilslutningspunkter");
--
}}}

In case it isn't clear, the index names in the SQL comment are "mine" from
the Meta: section of the model, but the index names used in the actual SQL
are the much longer autogenerated ones.

I believe this should be fixed with a construct like
https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L967
so autogenerated names are only used when 'name' not in kwargs.

--
Ticket URL: <https://code.djangoproject.com/ticket/30846>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 7, 2019, 5:06:20 AM10/7/19
to django-...@googlegroups.com
#30846: GeoDjango not respecting index names
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: nobody
Rasmussen |

Type: Bug | Status: new
Component: GIS | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:1>

Django

unread,
Oct 7, 2019, 9:16:54 AM10/7/19
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.

-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: nobody
Rasmussen |
Type: Bug | Status: new
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* version: 2.2 => master
* stage: Unreviewed => Accepted


Comment:

Thanks for the report. Agreed, we should respect `Index.name` for spatial
indexes.

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:2>

Django

unread,
Oct 7, 2019, 11:42:04 AM10/7/19
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: nobody
Rasmussen |
Type: Bug | Status: new

Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* easy: 0 => 1


Comment:

Tentatively set easy picking (without thorough examination).

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:3>

Django

unread,
Oct 9, 2019, 11:27:27 AM10/9/19
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: Ahisahar
Rasmussen | Pretel
Type: Bug | Status: assigned

Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahisahar Pretel):

* status: new => assigned
* owner: nobody => Ahisahar Pretel


Comment:

I think I can take a look at this if no one started working already on
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:4>

Django

unread,
Jan 21, 2020, 12:08:51 AM1/21/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner:
Rasmussen | Pratik1999

Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Pratik1999):

* owner: Ahisahar Pretel => Pratik1999


Comment:

This ticket seems inactive. So I am assigning it to myself

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:5>

Django

unread,
Jan 24, 2020, 7:39:54 AM1/24/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner:
Rasmussen | Pratik1999
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Pratik1999):

https://github.com/Pratik1999/django-1/tree/ticket_30846

These are the changes I have made, shall I submit the pull request? Or
more changes are needed?

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:6>

Django

unread,
Jan 24, 2020, 8:15:15 AM1/24/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner:
Rasmussen | Pratik1999
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

Pratik1999, PR is the proper place to discuss patches. At first glance,
tests are missing.

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:7>

Django

unread,
Jan 24, 2020, 10:05:16 AM1/24/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner:
Rasmussen | Pratik1999
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmad Abdallah):

* cc: Ahmad Abdallah (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:8>

Django

unread,
Feb 10, 2020, 2:20:14 AM2/10/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: Pratik
Rasmussen | Kumar

Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Pratik Kumar):

* has_patch: 0 => 1


Comment:

pull request :
[https://github.com/django/django/pull/12440]

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:9>

Django

unread,
Feb 10, 2020, 7:38:40 AM2/10/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: Pratik
Rasmussen | Kumar
Type: Bug | Status: assigned
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:10>

Django

unread,
Feb 10, 2020, 9:26:35 AM2/10/20
to django-...@googlegroups.com
#30846: postgis backend doesn't respect custom index names.
-------------------------------------+-------------------------------------
Reporter: Thomas Steen | Owner: Pratik
Rasmussen | Kumar
Type: Bug | Status: closed
Component: GIS | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"20ba3ce4ac8e8438070568ffba76f7d8d4986a53" 20ba3ce4]:
{{{
#!CommitTicketReference repository=""
revision="20ba3ce4ac8e8438070568ffba76f7d8d4986a53"
Fixed #30846 -- Made PostGIS backend respect Index's name argument.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30846#comment:11>

Reply all
Reply to author
Forward
0 new messages