#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. -- 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/062.0af1e689898eb582014f0fefadc29904%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.