[Django] #22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a non-concrete field

13 views
Skip to first unread message

Django

unread,
Mar 11, 2014, 6:10:20 PM3/11/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
----------------------------------------------+--------------------
Reporter: gwahl@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
When upgrading from 1.6.1 to 1.6.2, I encountered a new error in my
application. Basically, a non-concrete field is ending up in
`query.related_select_cols`, then `SQLCompiler.get_columns` tries to use
the field's column to build sql, when the field doesn't even have a
column. The error manifests as trying to call `quote_name(None)`.


{{{
File "django/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "django/django/db/models/sql/compiler.py", line 709, in
results_iter
for rows in self.execute_sql(MULTI):
File "django/django/db/models/sql/compiler.py", line 772, in execute_sql
sql, params = self.as_sql()
File "django/django/db/models/sql/compiler.py", line 82, in as_sql
out_cols, s_params = self.get_columns(with_col_aliases)
File "django/django/contrib/gis/db/models/sql/compiler.py", line 88, in
get_columns
r = self.get_field_select(field, table, col)
File "django/django/contrib/gis/db/models/sql/compiler.py", line 207, in
get_field_select
field_sel = sel_fmt % self._field_column(field, alias, column)
File "django/django/contrib/gis/db/models/sql/compiler.py", line 248, in
_field_column
self.connection.ops.quote_name(column or field.column))
File "django/django/db/backends/postgresql_psycopg2/operations.py", line
97, in quote_name
if name.startswith('"') and name.endswith('"'):
AttributeError: 'NoneType' object has no attribute 'startswith'
}}}

The backported fix for #21413, commit 0f272629, was the commit that
introduced the bug.

In `get_default_columns`, the GIS sql compiler uses
`get_fields_with_model`:
<https://github.com/django/django/blob/master/django/contrib/gis/db/models/sql/compiler.py#L127>

While the normal compiler uses `get_concrete_fields_with_model`:
<https://github.com/django/django/blob/master/django/db/models/sql/compiler.py#L296>

Changing the GIS compiler to use `get_concrete_fields_with_model` fixes
the issue. I'm not anywhere near familiar enough with this code to get a
minimal test case, so I'm hoping someone else can help and get this fixed.

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

Django

unread,
Mar 11, 2014, 6:25:27 PM3/11/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------

Reporter: gwahl@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by gwahl@…):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I check on master and the same issue exists.

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

Django

unread,
Mar 12, 2014, 6:24:35 PM3/12/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Uncategorized | Status: assigned

Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bak1an):

* owner: nobody => bak1an
* status: new => assigned


Comment:

I will try to figure out what's going on here.

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

Django

unread,
Mar 20, 2014, 4:58:59 PM3/20/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: assigned

Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


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

Django

unread,
Mar 29, 2014, 2:28:11 AM3/29/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed

Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed

Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Anssi Kääriäinen <akaariai@…>):

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


Comment:

In [changeset:"21f208e66e6472b8db8cdfd7cd1102d71bb15733"]:
{{{
#!CommitTicketReference repository=""
revision="21f208e66e6472b8db8cdfd7cd1102d71bb15733"
Fixed #22250 -- regression in gis compiler for non-concrete fields

Thanks to gw...@fusionbox.com for the report.
}}}

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

Django

unread,
Mar 29, 2014, 2:29:26 AM3/29/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Anssi Kääriäinen <akaariai@…>):

In [changeset:"a6a0800579c806d54af7edd425063be8de4051ab"]:
{{{
#!CommitTicketReference repository=""
revision="a6a0800579c806d54af7edd425063be8de4051ab"
[1.7.x] Fixed #22250 -- regression in gis compiler for non-concrete fields

Thanks to gw...@fusionbox.com for the report.

Backport of 21f208e66e from master
}}}

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

Django

unread,
Mar 29, 2014, 2:30:34 AM3/29/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Anssi Kääriäinen <akaariai@…>):

In [changeset:"31892af3f03fa75dd59a2f70beebb29993098778"]:
{{{
#!CommitTicketReference repository=""
revision="31892af3f03fa75dd59a2f70beebb29993098778"
[1.6.x] Fixed #22250 -- regression in gis compiler for non-concrete fields

Thanks to gw...@fusionbox.com for the report.

Backport of 21f208e66e from master
}}}

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

Django

unread,
Mar 31, 2014, 7:12:15 AM3/31/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d57ba04d890bab2d5ebe494e5e23d7374d658036"]:
{{{
#!CommitTicketReference repository=""
revision="d57ba04d890bab2d5ebe494e5e23d7374d658036"
Added 1.6.3 release note for refs #22250.
}}}

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

Django

unread,
Mar 31, 2014, 7:12:38 AM3/31/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"916f0de74ba00f65cc789c075ce94f7fba858976"]:
{{{
#!CommitTicketReference repository=""
revision="916f0de74ba00f65cc789c075ce94f7fba858976"
[1.6.x] Added 1.6.3 release note for refs #22250.

Backport of d57ba04d89 from master
}}}

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

Django

unread,
Mar 31, 2014, 7:12:38 AM3/31/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"25da849896c86c382da6337e719ef57460a77c85"]:
{{{
#!CommitTicketReference repository=""
revision="25da849896c86c382da6337e719ef57460a77c85"
[1.7.x] Added 1.6.3 release note for refs #22250.

Backport of d57ba04d89 from master
}}}

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

Django

unread,
Mar 31, 2014, 12:21:19 PM3/31/14
to django-...@googlegroups.com
#22250: Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a
non-concrete field
-------------------------------------+-------------------------------------
Reporter: gwahl@… | Owner: bak1an
Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) | Resolution: fixed
Severity: Release blocker | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by gwahl@…):

This fix worked for me, thanks.

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

Reply all
Reply to author
Forward
0 new messages