Re: [Django] #35394: Warning if `postgres` database has been rename (e.g. DigitalOcean managed) (was: Warning if 'postgres' database has been rename (e.g. DigitalOcean managed))

2024-04-22 Thread Django
#35394: Warning if `postgres` database has been rename (e.g. DigitalOcean 
managed)
-+-
 Reporter:  Jeffry Babb  |Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  postgres default db  | Triage Stage:
  name   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * summary:
 Warning if 'postgres' database has been rename (e.g. DigitalOcean
 managed)
 =>
 Warning if `postgres` database has been rename (e.g. DigitalOcean
 managed)


Old description:

> This warning is thrown if the 'postgres' database does not exist on the
> server.  DigitalOcean renames this database to 'defaultdb' which seems to
> raise this error in dango/db/backends/base/base.py
>

> {{{
> except (Database.DatabaseError, WrappedDatabaseError):
> if cursor is not None:
> raise
> warnings.warn(
> "Normally Django will use a connection to the 'postgres'
> database "
> "to avoid running initialization queries against the
> production "
> "database when it's not needed (for example, when running
> tests). "
> "Django was unable to create a connection to the
> 'postgres' database "
> "and will use the first PostgreSQL database instead.",
> RuntimeWarning,
> )
> }}}
>
> I have searched in the LIBPQ parameters can can't find a setting that
> allows me to specify this name change as Django seems to have hard-coded
> the search for the 'postgres' db name or is looking for it in a key
> called 'service' around line 193 and 218 in base.py.

New description:

 This warning is thrown if the `postgres` database does not exist on the
 server.  DigitalOcean renames this database to 'defaultdb' which seems to
 raise this error in dango/db/backends/postgresql/base.py

 {{{
 except (Database.DatabaseError, WrappedDatabaseError):
 if cursor is not None:
 raise
 warnings.warn(
 "Normally Django will use a connection to the 'postgres'
 database "
 "to avoid running initialization queries against the
 production "
 "database when it's not needed (for example, when running
 tests). "
 "Django was unable to create a connection to the
 'postgres' database "
 "and will use the first PostgreSQL database instead.",
 RuntimeWarning,
 )
 }}}

 I have searched in the LIBPQ parameters can can't find a setting that
 allows me to specify this name change as Django seems to have hard-coded
 the search for the `postgres` db name or is looking for it in a key called
 'service' around line 193 and 218 in base.py.

--
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f078899cb-d4528def-1069-485c-8791-0f2ac8eb4501-00%40eu-central-1.amazonses.com.


Re: [Django] #35394: Warning if 'postgres' database has been rename (e.g. DigitalOcean managed)

2024-04-22 Thread Django
#35394: Warning if 'postgres' database has been rename (e.g. DigitalOcean 
managed)
-+-
 Reporter:  Jeffry Babb  |Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  needsinfo
 Keywords:  postgres default db  | Triage Stage:
  name   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * resolution:   => needsinfo
 * status:  new => closed

Comment:

 Hello Jeffry, thank you for taking the time to submit this report.

 We would need more information to fully triage the issue, as I only see
 the `postgres` DB name hardcoded in two places:
 1. `get_connection_params` in
 
[https://github.com/django/django/blob/main/django/db/backends/postgresql/base.py#L282
 django/db/backends/postgresql/base.py], specifically when `NAME` is None.
 2. `settings_to_cmd_args_env` in
 
[https://github.com/django/django/blob/main/django/db/backends/postgresql/client.py#L28
 django/db/backends/postgresql/client.py] when the dbname is unset.

 A few questions:

 1. Could you please add specific details on when and where are you getting
 the warning? The warning text mentions that the `postgres` DB may be used
 in context such as things like running tests. Are you running the test
 suite in Heroku for example?
 2. Is there a specific issue that this warning triggers for you? If
 everything is working well, you could just ignore the specific warning
 with filters.
 3. Can you provide detailed instructions for reproducing locally/outside
 Heroku? Have you double check that the DB name is set properly?
 4. Did you try seeking initial help in the
 [https://forum.djangoproject.com/ Django Forum], to double check whether
 this is truly an issue in Django and not in your setup?

 I'll be closing this ticket as `needsinfo` following the
 [https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
 tickets/#closing-tickets ticket triaging process].
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f0787645e-0d9b2cd4-ef72-407d-b7bc-8ec55d0bd558-00%40eu-central-1.amazonses.com.