#22250 closed Bug (fixed)
Regression in 1.6.1->1.6.2 -- GIS sql compiler tries to generate sql for a non-concrete field
Reported by: | Owned by: | Anton Baklanov | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (10)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I will try to figure out what's going on here.
comment:3 by , 11 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I check on master and the same issue exists.