#31956: QuerySet.order_by() chained with values() crashes on JSONField with a
custom decoder on PostgreSQL.
-------------------------------------+-------------------------------------
Reporter: Marc DEBUREAUX | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Andrew):
How did this *manage* to break basic querying?
Replying to [comment:10 Mariusz Felisiak]:
> Moreover we're aware of this behavior change. Is there any reason to use
a row cursor and SQL instead of the ORM? You can always use `json.loads()`
on fetched data.
This is just silly. Yes, there are *obviously* reasons to use raw sql
over an ORM in some cases, this is not new. Putting a tiny note in a
release that no one will see isn't enough. This needs to be documented
front and center in the raw sql main docs and the postgres areas, because
I did read those and no hint.
"just use x" is a bad solution to something that broke basic
functionality, and isn't necessarily even easy to do. It turns what is a
simple automapping into manual mapping, at best. I guess we could
implement something that parses python typehints on result classes detects
if the cursor has been effed with and is returning the wrong data type,
though. How many more data types do you expect to be broken on purpose in
the future?
Also, the workaround is just to add `::json` to any `jsonb` columns in raw
queries. So this is only broken for HALF types?
It feels like an easy fix for one problem which ignores some other
underlying issue, breaking use cases that a few people don't personally
use. If I want a query to work in the future *as written* am I going to
have to start creating raw psycopg2 cursors? Because those still work!
--
Ticket URL: <https://code.djangoproject.com/ticket/31956#comment:16>
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/064.a6ee5c3d6d49588b197be8686d6f69fe%40djangoproject.com.