#35778: Use native JSONObject on Postgres 16+ with server side bindings
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
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 john-parton):
Good info with prepared statements. That meshes with my intuition.
Regarding `Func(expression, template="CAST(%(expressions)s AS text)")`,
that has a bit of code smell to me, abstraction inversion.
I sort of question the wisdom of using the `::` operation on postgres at
all. The comment
https://github.com/django/django/blob/6765b6adf924c1bc8792a4a454d5a788c1abc98e/django/db/models/functions/comparison.py#L52-L61
suggests it makes the SQL "more readable", which is true in the context
that you're more familiar with postgres than any RDMS. I'd argue that the
Cast(...) function is possibly "more readable" than the double colon in
the case that the user is more familiar with other databases or just SQL
in general, and *relevant to this issue* it is more readable in the case
that there are colons used elsewhere in the expression, i.e. JSON_OBJECT.
(It's so unreadable with the double colons that even the parser can't
"read" it, haha)
I think an argument can be made to just delete those 10 lines and have the
output SQL closer to standards. It seems like part of the underlying
philosophy of moving postgres from JSONB_BUILD_OBJECT to JSON_OBJECT is to
settle on standards, so in that sense, reworking Cast() is in line with
the overall spirit of the project.
--
Ticket URL: <https://code.djangoproject.com/ticket/35778#comment:9>
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/010701924e1a93ec-ad29084b-0c78-48cd-aa9e-391f6f635a7d-000000%40eu-central-1.amazonses.com.