#36133: Passing expression with wrongly attributed text output_field to Concat
crashes on Postgres due the lack of casting
-------------------------------------+-------------------------------------
     Reporter:  Siburg               |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  Cast,                |             Triage Stage:
  ExpressionWrapper                  |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Siburg):

 Thank you. I'm using PostgreSQL 14 and psycopg == 3.2.4 . Just tried it
 out and the test passes with SQLite, so it is indeed a PostgreSQL thing.

 I appreciate your simplification of removing the `ExpressionWrapper`
 altogether. Happy to confirm that indeed works, and will adopt that in my
 code.

 But, still surprised by the unexpected breakage in Django 5.1. I naively
 expected that specifying `output_field=models.CharField()` for an
 `ExpressionWrapper` would lead to the intended result. I think that is the
 gist of https://code.djangoproject.com/ticket/26650 as well. So it's
 annoying that such a specification is useless, and the `ExpressionWrapper`
 will provide a `bigint` anyway. Perhaps it would be good to clarify the
 documentation in
 https://docs.djangoproject.com/en/5.1/ref/models/expressions/#output-
 field.

 Thinking a little more about it, I realize that `output_field` is a very
 trick thing and can depend on the database. For example, I am aware from
 painful experience that SQLite causes problems with `DecimalField`. So I
 don't have any clear solution  myself for this breakage in 5.1.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36133#comment:6>
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 visit 
https://groups.google.com/d/msgid/django-updates/010701949696b10d-5c2f97b0-51c4-4835-86d4-41c42a545582-000000%40eu-central-1.amazonses.com.

Reply via email to