#34838: GeoDjango database functions incompatible with GeneratedField
-------------------------------------+-------------------------------------
Reporter: Paolo Melchiorre | Owner: Paolo
| Melchiorre
Type: Bug | Status: assigned
Component: GIS | Version: dev
Severity: Release blocker | Resolution:
Keywords: field, database, | Triage Stage: Accepted
generated, gis, feodjango |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Paolo Melchiorre):
Replying to [comment:2 Simon Charette]:
> Maybe this can be done at the `GeneratedField.get_col` level where the
returned `Col` instance defaults to `output_field=self.output_field`
instead of `self`.
>
> {{{#!diff
> diff --git a/django/db/models/fields/generated.py
b/django/db/models/fields/generated.py
> index 0980be98af..948d11d003 100644
> --- a/django/db/models/fields/generated.py
> +++ b/django/db/models/fields/generated.py
> @@ -48,6 +48,11 @@ def contribute_to_class(self, *args, **kwargs):
> for lookup_name, lookup in
self.output_field.get_class_lookups().items():
> self.register_lookup(lookup, lookup_name=lookup_name)
>
> + def get_col(self, alias, output_field=None):
> + if output_field is None:
> + output_field = self.output_field
> + return super().get_col(alias, output_field)
> +
> def generated_sql(self, connection):
> return self._resolved_expression.as_sql(
> compiler=connection.ops.compiler("SQLCompiler")(
> }}}
Thanks for the suggestion Simon. After reading your comment I had defined
the `get_col` function exactly as you then sent it. I think I also wrote a
couple of correct tests. I'm going to open the PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/34838#comment:3>
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/0107018a902121b2-ec2a1897-af29-4855-a1a0-dedf34f8389b-000000%40eu-central-1.amazonses.com.