[Django] #35016: Missing documentation for setting libpq options with the PostgreSQL backend

9 views
Skip to first unread message

Django

unread,
Dec 5, 2023, 11:41:06 AM12/5/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-----------------------------------------+------------------------
Reporter: SpecLad | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
As far as I can see, when a database uses the
`django.db.backends.postgresql` engine, any options from the `OPTIONS` key
that are not recognized by the engine itself are passed directly to the
underlying libpq library. This way you can set options like
[https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-
SSLMODE `sslmode`].

But this doesn't seem to actually be documented anywhere, so it's unclear
whether this is actually a supported feature or just an implementation
artifact.

If this really is supported, then it should be documented - presumably in
[https://docs.djangoproject.com/en/5.0/ref/databases/#postgresql-notes
PostgreSQL notes].

--
Ticket URL: <https://code.djangoproject.com/ticket/35016>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 6, 2023, 12:01:51 AM12/6/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
--------------------------------------+------------------------------------
Reporter: Roman Donchenko | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

This vary depending on your database backend (as
[https://docs.djangoproject.com/en/dev/ref/settings/#std-setting-OPTIONS
documented]), but I agree that it's worth mentioning that the PostgreSQL
backend passes the content of OPTIONS as keyword arguments to the
connection constructor, allowing for more advanced control of driver
behavior.

Would you like to prepare a patch?

--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:1>

Django

unread,
Dec 7, 2023, 2:53:02 AM12/7/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
--------------------------------------+------------------------------------
Reporter: Roman Donchenko | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Yashas Donthi):

I'd like to prepare a patch

--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:2>

Django

unread,
Dec 7, 2023, 4:02:25 AM12/7/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: Yashas
Type: | Donthi
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Yashas Donthi):

* owner: nobody => Yashas Donthi
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:3>

Django

unread,
Dec 7, 2023, 6:45:16 AM12/7/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: Yashas
Type: | Donthi
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.0
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
-------------------------------------+-------------------------------------
Changes (by Yashas Donthi):

* has_patch: 0 => 1


Old description:

> As far as I can see, when a database uses the
> `django.db.backends.postgresql` engine, any options from the `OPTIONS`
> key that are not recognized by the engine itself are passed directly to
> the underlying libpq library. This way you can set options like
> [https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-
> CONNECT-SSLMODE `sslmode`].
>
> But this doesn't seem to actually be documented anywhere, so it's unclear
> whether this is actually a supported feature or just an implementation
> artifact.
>
> If this really is supported, then it should be documented - presumably in
> [https://docs.djangoproject.com/en/5.0/ref/databases/#postgresql-notes
> PostgreSQL notes].

New description:

As far as I can see, when a database uses the
`django.db.backends.postgresql` engine, any options from the `OPTIONS` key
that are not recognized by the engine itself are passed directly to the
underlying libpq library. This way you can set options like
[https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-
SSLMODE `sslmode`].

But this doesn't seem to actually be documented anywhere, so it's unclear
whether this is actually a supported feature or just an implementation
artifact.

If this really is supported, then it should be documented - presumably in
[https://docs.djangoproject.com/en/5.0/ref/databases/#postgresql-notes
PostgreSQL notes].

PR #17586 to fix this: https://github.com/django/django/pull/17586

--

--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:4>

Django

unread,
Dec 8, 2023, 2:24:38 AM12/8/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: Yashas
Type: | Donthi
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:5>

Django

unread,
Dec 8, 2023, 3:45:46 AM12/8/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: Yashas
Type: | Donthi
Cleanup/optimization | Status: closed
Component: Documentation | Version: 5.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"eeb2119985d9879b1d9ac3730ea0b53c0c019221" eeb21199]:
{{{
#!CommitTicketReference repository=""
revision="eeb2119985d9879b1d9ac3730ea0b53c0c019221"
Fixed #35016 -- Doc'd that DATABASES["OPTIONS"] are passed to new
PostgreSQL connections.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:6>

Django

unread,
Dec 8, 2023, 3:45:58 AM12/8/23
to django-...@googlegroups.com
#35016: Missing documentation for setting libpq options with the PostgreSQL backend
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: Yashas
Type: | Donthi
Cleanup/optimization | Status: closed
Component: Documentation | Version: 5.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"6c992dc0031f9f3134aa50d1bc00b1eee581ae13" 6c992dc0]:
{{{
#!CommitTicketReference repository=""
revision="6c992dc0031f9f3134aa50d1bc00b1eee581ae13"
[5.0.x] Fixed #35016 -- Doc'd that DATABASES["OPTIONS"] are passed to new
PostgreSQL connections.

Backport of eeb2119985d9879b1d9ac3730ea0b53c0c019221 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35016#comment:7>

Reply all
Reply to author
Forward
0 new messages