Opened 5 years ago

Closed 5 years ago

#31463 closed New feature (duplicate)

Apply OPTIONS in database settings to dbshell.

Reported by: Dulmandakh Owned by: nobody
Component: Database layer (models, ORM) Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Dulmandakh)

When I use django.db.backends.postgresql, and set OPTIONS like below, it would apply to psycopg2 connections, but not dbshell. Developers expect that DB connection configuration would apply in all cases.

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "db",
        "HOST": "127.0.0.1",
        "OPTIONS": {"options": "-c default_text_search_config=simple"}
    }
}

Entering below command in dbshell would show pg_catalog.english instead of pg_catalog.simple.

SHOW default_text_search_config;

https://github.com/django/django/pull/12715

Change History (7)

comment:1 by Carlton Gibson, 5 years ago

Hi. Thanks for the report.

We're just about to merge #29501, which will allow passing extra options to dbshell. I know it's not exactly what you've asked for but would it address your use-case do you think?

Thanks.

comment:2 by Dulmandakh, 5 years ago

#29501 would allow developers to pass SQL to dbshell and execute it. Mine is about dbshell connection configuration, then make it consistent with psycopg2 connection configuration.

comment:3 by Dulmandakh, 5 years ago

I'm playing with full text search, and been wondering why same SQL works different in dbshell and test cases. after some digging, I found that dbshell doesn't pass OPTIONS down to sql, please see the PR https://github.com/django/django/pull/12715/

comment:4 by Simon Charette, 5 years ago

Also related to #30865, if we go this way all backends should be adjusted to support such pattern not solely Postgres.

comment:5 by Dulmandakh, 5 years ago

Simon Charette, I see. But not all backends are equal even documentation states that OPTIONS will depend on a backend.

comment:6 by Dulmandakh, 5 years ago

Description: modified (diff)

comment:7 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: newclosed
Summary: apply OPTIONS in database settings to dbshellApply OPTIONS in database settings to dbshell.
Type: UncategorizedNew feature

Duplicate of #23318.

Note: See TracTickets for help on using tickets.
Back to Top